adaptivemd.File¶
-
class
adaptivemd.File(location)[source]¶ Represents a file object at a specific location
File objects can but do not have to exist - you can check using the
File.createdattribute. If it is a positive number it represents the time stamp when it was created.Methods
__init__(location)args()Return a list of args of the __init__ function of a class base()Return the most parent class actually derived from StorableMixin clone()create a cloned object with equal attributes copy([target])copy file to a target create(scheduler)Mark file as being existent on a specific scheduler. descendants()Return a list of all subclassed objects from_dict(dct)get_file()Return the file content it has been loaded get_uuid()Create a new unique ID idx(store)Return the index which is used for the object in the given store. link([target])link file to a target load([scheduler])Load a local file into memory modified()Mark a file as being altered and not existent anymore move([target])move file to a target named(name)Attach a .name property to an object objects()Returns a dictionary of all storable objects remove()remove file set_file(content)Set the file content. to_dict()touch()touch file transfer([target])transfer file to a target Attributes
ACTIVE_LONGCREATION_COUNTINSTANCE_UUIDallowed_drivesbase_clsReturn the base class base_cls_nameReturn the name of the base class basenamereturns: the file basename basename_shortreturns: the basename without extension clsReturn the class name as a string createddefault_drivedirnamereturns: the path of the directory, like os.path.dirname drivereturn the prefix name existsreturns: True if the file exists, i.e. has a positive created timestamp extensionreturns: the filename extension or ‘’ of non exists generatorhas_filereturns: True if the file content is attached. is_folderreturns: True if location is a folder is_tempreturns: True when the location is a temporary folder that might be pathreturns: the complete path without prefix shortreturns: a shortened form of the path splitreturns: split_drivereturns: * str – the drive (prefix with ://) taskurlreturns: return the full form always with a prefix use_absolute_local_paths-
clone()[source]¶ create a cloned object with equal attributes
Returns: the same type as this object Return type: Location
-
create(scheduler)[source]¶ Mark file as being existent on a specific scheduler.
This should only work for file in
staging://,shared://,sandbox://orfile://Files inworker://will potentially be deleted, others are already existingNotes
We usually assume that objects are immutable. The way to think about creation is that a file is something like a Promise and it promises a certain file with a name. Once it is created it is still the same file but now it exists and can be used.
The change of location is also a re-expression of the same location so that it is reusable.
-
modified()[source]¶ Mark a file as being altered and not existent anymore
Notes
Negative timestamps indicate the (negative) time when the object disappeared in the form described
-
exists¶ Returns: True if the file exists, i.e. has a positive created timestamp Return type: bool
-
copy(target=None)[source]¶ copy file to a target
Shortcut for
Copy(self, target)Parameters: target (Location or str) – the target location Returns: the copy action Return type: adaptivemd.FileTransaction
-
move(target=None)[source]¶ move file to a target
Shortcut for
Move(self, target)Parameters: target (Location or str) – the target location Returns: the move action Return type: adaptivemd.FileTransaction
-
link(target=None)[source]¶ link file to a target
Shortcut for
Link(self, target)Parameters: target (Location or str) – the target location Returns: the link action Return type: adaptivemd.FileTransaction
-
transfer(target=None)[source]¶ transfer file to a target
Shortcut for Transfer(self, target)
Parameters: target (Location or str) – the target location Returns: the transfer action Return type: adaptivemd.FileTransaction
-
remove()[source]¶ remove file
Shortcut for Remove(self)
Returns: the remove action Return type: adaptivemd.FileAction
-
touch()[source]¶ touch file
Shortcut for Touch(self)
Returns: the touch action Return type: adaptivemd.FileAction
-
load(scheduler=None)[source]¶ Load a local file into memory
If you later store the file its content will be stored as well
Parameters: scheduler (Scheduler or None) – if specifiied the scheduler can alter the filelocation with its usual rules. Normally you should not have to use it Returns: Return type: self
-
get_file()[source]¶ Return the file content it has been loaded
Returns: the file content, if it exists None else Return type: str or None
-
has_file¶ Returns: True if the file content is attached. Return type: bool
-