stow.artefacts
Artefact— Artefacts are the items that are being stored - it is possible that through another mechanism that these items are deleted and they are no longer able to workFile— A filesystem file object - a container of bytes representing some dataSubFile— A file object of a submanager. Wrapper for a complete Manager FileDirectory— A directory represents an local filesystems directory or folder. Directories hold references to other directories or filesSubDirectory— A directory object of a submanager. Wrapper for a complete Manager directory
Warning
Artefacts are created by managers - you should not initialise Artefact objects directly.
Classes
stow.artefacts.Artefact(manager, path)
Artefacts are the items that are being stored - it is possible that through another mechanism that these items are deleted and they are no longer able to work
manager(ManagerInterface) — The submanager this file belongs topath(str) — The file's relative path
accessedTime— UTC localised datetime of time file last modified by a write/append methodbasename— Basename of the artefact - holding directory path removed leaving filename and extensioncreatedTime— UTC localised datetime of time file last modified by a write/append methoddirectory— Directory object this artefact exists withinmanager— Return the manager object this Artefact belongs tomodifiedTime— UTC localised datetime of time file last modified by a write/append methodname— Name of artefact - forFilethis is without extensionpath— Return the manager relative path to this Artefact
save(path, force=False)
Save the artefact to a local location
path(str) — A local path where the Artefact is to be savedforce(bool, optional) — Ignore artefacts at the destination location
OperationNotPermitted— If the location given is a Directory and the get is not enforced
delete(force=False)
Delete this artefact from the disk
force(bool, optional) — An "are you sure" for directories
OperationNotPermitted— If directory and deletion has not been deleted
stow.artefacts.File(manager, path, size, modifiedTime, createdTime=None, accessedTime=None)
A filesystem file object - a container of bytes representing some data
manager(ManagerInterface) — The submanager this file belongs topath(str) — The file's relative pathsize(float) — The size in bytes of the file contentmodifiedTime(datetime) — The time the file was last modified via a write/append operation
accessedTime— UTC localised datetime of time file last modified by a write/append methodbasename— Basename of the artefact - holding directory path removed leaving filename and extensioncontent(bytes) — file content as bytescreatedTime— UTC localised datetime of time file last modified by a write/append methoddirectory— Directory object this artefact exists withinextension— File extension string - extention indicates file purpose and associated applicationsmanager— Return the manager object this Artefact belongs tomodifiedTime— UTC localised datetime of time file last modified by a write/append methodpath— Return the manager relative path to this Artefactsize— Size of file content in bytes
save(path, force=False)
Save the artefact to a local location
path(str) — A local path where the Artefact is to be savedforce(bool, optional) — Ignore artefacts at the destination location
OperationNotPermitted— If the location given is a Directory and the get is not enforced
delete(force=False)
Delete this artefact from the disk
force(bool, optional) — An "are you sure" for directories
OperationNotPermitted— If directory and deletion has not been deleted
localise()
Localise this File artefact
the absolute local path to the manager path
open(mode='r', **kwargs)
Context manager to allow the pulling down and opening of a file
stow.artefacts.Directory(manager, path, createdTime=None, modifiedTime=None, accessedTime=None)
A directory represents an local filesystems directory or folder. Directories hold references to other directories or files
manager(stow.Manager) — The manager this directory object belongs topath(str) — the manager relative path for the object
accessedTime— UTC localised datetime of time file last modified by a write/append methodbasename— Basename of the artefact - holding directory path removed leaving filename and extensioncreatedTime— UTC localised datetime of time file last modified by a write/append methoddirectory— Directory object this artefact exists withinmanager— Return the manager object this Artefact belongs tomodifiedTime— UTC localised datetime of time file last modified by a write/append methodname— Name of artefact - forFilethis is without extensionpath— Return the manager relative path to this Artefact
delete(force)— Delete this artefact from the diskempty()— Empty the directory of contentsisEmpty()(bool) — Check whether the directory has contentslocalise(path)(str) — Localise an artefact this directory or a child artefact with the provided path.ls(path,recursive)(typing.Set[Artefact]) — List the contents of this directory, or directory's directories.mkdir(path)(Directory) — Create a directory nested inside thisDirectorywith the relative path givenopen(path,mode,**kwargs)(io.IOBase) — Open a file and create a stream to that file. Expose interface ofopenrelpath(artefact)(str) — Assuming the artefact is a member of this directory, return a filepath which is relative to this directoryrm(path,recursive)— Remove an artefact at the given locationsave(path,force)— Save the artefact to a local locationtouch(path)(File) — Touch a file at given location relative to this Directory
save(path, force=False)
Save the artefact to a local location
path(str) — A local path where the Artefact is to be savedforce(bool, optional) — Ignore artefacts at the destination location
OperationNotPermitted— If the location given is a Directory and the get is not enforced
delete(force=False)
Delete this artefact from the disk
force(bool, optional) — An "are you sure" for directories
OperationNotPermitted— If directory and deletion has not been deleted
mkdir(path)
Create a directory nested inside this Directory with the relative path given
path(str) — Relative path to directory, path to new directory location
The newly created directory object
touch(path)
Touch a file at given location relative to this Directory
path(str) — The relative path to directory to touch new file
The newly created file object
relpath(artefact)
Assuming the artefact is a member of this directory, return a filepath which is relative to this directory
artefact(Artefact or str) — the artefact who's path will be made relative
the relative path to the artefact from this directory
ArtefactNotMember— raised when artefact is not a member of the directory
localise(path=None)
Localise an artefact this directory or a child artefact with the provided path.
path(str, optional) — Path of localisation
the absolute local path to the manager path
open(path, mode='r', **kwargs)
Open a file and create a stream to that file. Expose interface of open
path(str) — Path to directory objectmode(str, optional) — The open methodkwargs— kwargs to be passed to the interface of open
An IO object depending on the mode for interacting with the file
rm(path=None, recursive=False)
Remove an artefact at the given location
recursive(bool, optional) — If the target is a directory, whether to delete recursively the directories contentsartefact— Path that is to be deleted
OperationNotPermitted— In the even the target is a directory and recursive has not been toggled
ls(path=None, recursive=False)
List the contents of this directory, or directory's directories.
path(str, optional) — The path to sub directory whose contents is to be returnedrecursive(bool, optional) — Whether to recursively fetch all child contents for child directories
The collection of objects within the targeted directory
isEmpty()
Check whether the directory has contents
True when there is at least one item in the directory False when the directory is empty
empty()
Empty the directory of contents