Filesystem interfaces and data structures.
Current working directory related interfaces are provided in process.
Sequence
Iterable
Optional
TypeAlias0
os0
sys0
contextlib0
collections0
stat0
itertools0
functools0
shutil0
tempfile0
cachedcalls0
Selector
Segment0
type_codes0
Single character representations for file types. Primarily used by Path.fs_require.
type_codes = {
'*': None,
'/': 'directory',
'.': 'data',
'#': 'device',
'@': 'socket',
'|': 'pipe',
'&': 'link',
'!': 'void',
'?': 'unknown',
}
RequirementViolation0
Exception raised by Path.fs_require when requirements are not met.
RequirementViolationProperties
- r_violation
The subtype declaring the kind of violation that occurred.
'inaccessible'Path traversed through a non-directory file, or had insufficient permissions on the leading path.
'prohibited'The required permissions stated in r_properties were not available to the process.
- r_type
The required type issued to Path.fs_require.
- r_properties
The required properties issued to Path.fs_require.
- fs_type
The type of the file identified by fs_path.
RequirementViolation__init__0
__init__(self, subject, type, violation, rtype, properties)
RequirementViolation__str__192%
__str__(self)
Status0
File status interface providing symbolic names for the data packed in the system's status record, system.
StatusEngineering
Experimental. Helps isolate delayed imports. Likely undesired noise if a stat-cache is employed by Path.
Status__slots__0
__slots__ = ()
Status_fs_type_map0
_fs_type_map = {
stat.S_IFIFO: 'pipe',
stat.S_IFLNK: 'link',
stat.S_IFREG: 'data',
stat.S_IFDIR: 'directory',
stat.S_IFSOCK: 'socket',
stat.S_IFBLK: 'device',
stat.S_IFCHR: 'device',
}
Status_fs_subtype_map0
_fs_subtype_map = {
stat.S_IFBLK: 'block',
stat.S_IFCHR: 'character',
}
@property
Status_interpret_time0
Status_read_user30%
Status_read_group30%
Statusfrom_route10%
from_route(Class, route)
Statussystem0
The status record produced by the system (os.path.stat).
Statusfilename233%str
The name of the file.
Status__add__10%
__add__(self, operand)
Statussize233%int
Number of bytes contained by the file.
Statustype0str
Statussubtype250%Optional[str]
For POSIX-type systems, designates the kind of device: block or character.
Statuscreated20%
Time of creation; UTC. Not available on all systems.
Statuslast_modified0
Time of last modification; UTC.
Statuslast_accessed20%
Time of last access; UTC.
Statusmeta_last_modified20%
Time of last status change; UTC.
Statusowner10%
Statusgroup10%
Statussetuid10%
Statussetgid10%
Statussticky10%
Statusexecutable0bool
Whether the data file is considered executable by anyone.
Extended attributes are not checked.
Statussearchable433%bool
Whether the directory file is considered searchable by anyone.
Extended attributes are not checked.
path_string_cache0
path_string_cache(path)
Path0
Selector[str]Path implementation providing file system controls. files.root is provided for convenience, and process.fs_pwd is available for getting the working directory of the process.
Path__slots__0
__slots__ = ('context', 'points',)
PathViolation0
Violation = RequirementViolation
Path_root_path0
_root_path = _path_separator = os.path.sep
Path_fs_access0
_fs_access = staticmethod(functools.partial(
os.access,
effective_ids=(os.access in os.supports_effective_ids)
))
Path_fs_access_map0
_fs_access_map = {
'r': os.R_OK,
'w': os.W_OK,
'x': os.X_OK,
'/': 0,
'!': 0,
}
Pathfs_require196%
fs_require(self)
Pathfrom_path0
from_path(Class, path)
Construct a Path instance from the given absolute or relative path provided for string; if a relative path is specified, it will be relative to the current working directory as identified by os.path.getcwd.
This is usually the most appropriate way to instantiate a Path route from user input. The exception being cases where the current working directory is not the relevant context.
Pathfrom_relative0
from_relative(Class, context, path)
Return a new Route pointing to the file referenced by path; where path is a path relative to the context Path instance.
This function does not refer to the current working directory returned by os.path.getcwd; if this is desired, from_path is the appropriate constructor to use.
Pathfrom_absolute0
from_absolute(Class, path)
Pathfrom_absolute_parts0
from_absolute_parts(Class, start, *paths)
Path_partition_string0Iterable[Sequence[str]]
_partition_string(path)
Pathfrom_partitioned_string0
from_partitioned_string(Class, path)
Construct an absolute path while interpreting consecutive separators as distinct partitions.
Path__matmul__0
__matmul__(self, path)
Pathfs_tmpdir277%
fs_tmpdir(Class)
Create a temporary directory at a new route using a context manager.
A Path to the temporary directory is returned on entrance, and that same path is destroyed on exit.
Pathfs_tmpdirEngineering
The use of specific temporary files is avoided as they have inconsistent behavior on some platforms.
Path__repr__180%
__repr__(self)
Path__str__0
__str__(self)
Pathfullpath0str
Returns the full filesystem path designated by the route.
Pathbytespath0bytes
Returns the full filesystem path designated by the route as a bytes object returned by encoding the fullpath in sys.getfilesystemencoding with 'surrogateescape' as the error mode.
Pathjoin190%str
join(self, *parts)
Construct a string path using self as the prefix and appending the path fragments from parts.
Segment instances should be given with an asterisk applied to the argument.
Pathfilename0
Filesystem specific alias for identifier.
Pathextension0
Return the last dot-extension of the filename. None if the filename has no . characters at all.
Pathsuffix_filename0
suffix_filename(self, appended_suffix)
Modify the name of the file adding the given suffix.
Returns a new Path Route.
Pathsuffix0
suffix = suffix_filename
Pathprefix_filename0
prefix_filename(self, prefix_string)
Modify the name of the file adding the given prefix.
Returns a new Path Route.
Pathprefix0
prefix = prefix_filename
Path__pos__0
__pos__(self)
Pathfs_path_string0str
fs_path_string(self)
Construct a normalized string representing the path to the file.
Relative resolution must still be explicitly performed, but empty path entries delimiting partitions are eliminated.
Path__fspath__0
__fspath__ = fs_path_string
Pathfs_status0Status
fs_status(self)
Pathfs_type0str
fs_type(self)
The type of file the route points to. Transforms the result of an os.path.stat call into a string describing the st_mode field.
Pathfs_typeReturns
'directory''data''pipe''socket''device''void'
If no file is present at the path or a broken link is present, 'void' will be returned.
Pathfs_executable350%bool
fs_executable(self)
Whether the file at the route is considered to be an executable.
Pathfs_follow_links0Iterable[Selector]
fs_follow_links(self)
Pathfs_iterfiles193%
fs_iterfiles()
Generate Path instances identifying the files held by the directory, self. By default, all file types are included, but if the type parameter is given, only files of that type are returned.
If self is not a directory or cannot be searched, an empty iterator is returned.
Pathfs_list0
fs_list(self)
Retrieve the list of files contained by the directory referred to by self. Returns a pair, the sequence of directories and the sequence of data files.
Sockets, pipes, devices, and other non-data files are not retained in the list.
Pathfs_index0
fs_index(self)
Generate pairs of directories associated with their files.
Sockets, pipes, devices, broken links, and other non-data files are not retained in the lists.
Pathfs_snapshot1372%
fs_snapshot()
Pathfs_since0Iterable[tuple[int, Selector]]
fs_since(self, since)
Identify the set of files that have been modified since the given point in time.
The resulting iterable does not include directories.
Pathfs_sinceParameters
Pathfs_real175%
fs_real(self)
Pathexists233%bool
exists(self)
Query the filesystem and return whether or not the file exists.
A Route to a symbolic link will return False if the target does not exist.
Pathfs_modified0
fs_modified(self)
Update the modification time of the file identified by self.
Pathfs_size0int
fs_size(self)
Return the size of the file as depicted by os.path.stat.
Pathget_last_modified0int
get_last_modified(self)
Return the modification time of the file.
Pathset_last_modified0
set_last_modified(self, time)
Set the modification time of the file identified by the Route.
Pathget_text_content0str
get_text_content(self)
Retrieve the entire contents of the file as a str.
Pathset_text_content0None
set_text_content(self, string)
Modify the regular file identified by self to contain the given string.
Pathmeta30%
meta(self)
Return file specific meta data.
| WARNING | |
Preliminary API. |
Pathfs_void370%
fs_void(self)
Pathfs_replace0
fs_replace(self, replacement)
Pathfs_linear156%
fs_linear(self)
Pathfs_reduce827%
fs_reduce(self, discarded)
Pathfs_link_relative554%
fs_link_relative(self, path)
Pathfs_link_absolute544%
fs_link_absolute(self, path)
Pathfs_init0
fs_init(self)
Create and initialize a data file at the route using the given data.
If data is None, no write operation will occur for pre-existing files. If data is not None, the bytes will be written regardless.
Returns the route instance, self. Leading directories will be created as needed.
Pathfs_alloc0
fs_alloc(self)
Pathfs_mkdir0
fs_mkdir(self)
Pathfs_open362%
fs_open(self, *args, **kw)
Open the file pointed to by the route.
If the file doesn't exist, create it; if the directories leading up to the file don't exist, create the directories too.
Pathfs_load0bytes
fs_load(self)
Pathfs_store0
fs_store(self, data)
root0
The Path to the root directory of the operating system.
root = Path(None, ())
null0
The Path to the file that has no content and will discard writes.
null = root/'dev'/'null'
empty0
The Path to the directory that contains no files.
empty = (root/'var'/'empty').delimit()