ProtocolPath

class hep_rfm.ProtocolPath(path, path_checker=None)[source]

Bases: object

Base class to represent a protocol to manage a path to a file. The protocol IDs are defined at runtime, using ProtocolPath.register_protocol(). These IDs are saved in the registered classes on the attribute “pid”. It is very important not to ovewrite this value, since it would lead to undefined behaviour. The protocols are saved on a dictionary, where the keys are the protocol IDs. This is an abstract class, and any class inheriting from it must override the following methods: 1. ProtocolPath.copy() 2. ProtocolPath.mkdirs()

Parameters:
  • path (str) – path to save, pointing to a file.
  • path_checker (function) – possible function that checks the the given path actually corresponds to the protocol. It must take a path as argument and return a bool.
Raises:

ValueError – if the path does not satisfy the requirements from “path_checker”.

Attributes Summary

path Return the associated path to the file.

Methods Summary

copy(source, target) Copy the source file to the target using this protocol.
mkdirs() Make directories to the file path within this protocol.
with_modifiers([modifiers]) Return an instance of this class after applying modifications.

Attributes Documentation

path

Return the associated path to the file.

Returns:associated path.
Return type:str

Methods Documentation

static copy(source, target)[source]

Copy the source file to the target using this protocol. The target must be accessible. It must return a subprocess.Popen object. In this case, this is an abstract method.

Parameters:
Returns:

running process copying the file in the current location to the target.

Return type:

subprocess.Popen

mkdirs()[source]

Make directories to the file path within this protocol. It must return a subprocess.Popen object. In this case, this is an abstract method.

Returns:running process to make the necessary directories to the target.
Return type:subprocess.Popen
with_modifiers(modifiers=None)[source]

Return an instance of this class after applying modifications. The input dictionary can contain information not understood for a given hep_rfm.ProtocolPath. By default the same class, with no modifications, is returned.

Parameters:modifiers (dict) – information to modify the path of this class.
Returns:modified instance if a modification is applied. Otherwise same instance.
Return type:ProtocolPath