Path#
- class polpo.preprocessing.load.pregnancy.Path(*args, **kwargs)[source]#
Bases:
PurePath
PurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.
- absolute()[source]#
Return an absolute version of this path by prepending the current working directory. No normalization or symlink resolution is performed.
Use resolve() to get the canonical path to a file.
- property anchor#
The concatenation of the drive and root, or ‘’.
- as_posix()#
Return the string representation of the path with forward (/) slashes.
- as_uri()#
Return the path as a ‘file’ URI.
- classmethod cwd()[source]#
Return a new path pointing to the current working directory (as returned by os.getcwd()).
- property drive#
The drive prefix (letter or UNC path), if any.
- expanduser()[source]#
Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
- glob(pattern)[source]#
Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
- hardlink_to(target)[source]#
Make this path a hard link pointing to the same file as target.
Note the order of arguments (self, target) is the reverse of os.link’s.
- classmethod home()[source]#
Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)).
- is_absolute()#
True if the path is absolute (has both a root and, if applicable, a drive).
- is_file()[source]#
Whether this path is a regular file (also True for symlinks pointing to regular files).
- is_relative_to(*other)#
Return True if the path is relative to another path or False.
- is_reserved()#
Return True if the path contains one of the special names reserved by the system, if any.
- iterdir()[source]#
Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’.
- joinpath(*args)#
Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored).
- lchmod(mode)[source]#
Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
- link_to(target)[source]#
Make the target path a hard link pointing to this path.
Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.
Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use hardlink_to() instead.
- lstat()[source]#
Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
- match(path_pattern)#
Return True if this path matches the given pattern.
- property name#
The final path component, if any.
- open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)[source]#
Open the file pointed by this path and return a file object, as the built-in open() function does.
- property parent#
The logical parent of the path.
- property parents#
A sequence of this path’s logical parents.
- property parts#
An object providing sequence-like access to the components in the filesystem path.
- read_text(encoding=None, errors=None)[source]#
Open the file in text mode, read it, and close the file.
- relative_to(*other)#
Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError.
- rename(target)[source]#
Rename this path to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- replace(target)[source]#
Rename this path to the target path, overwriting if that path exists.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
- resolve(strict=False)[source]#
Make the path absolute, resolving all symlinks on the way and also normalizing it.
- rglob(pattern)[source]#
Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
- property root#
The root of the path, if any.
- samefile(other_path)[source]#
Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
- stat(*, follow_symlinks=True)[source]#
Return the result of the stat() system call on this path, like os.stat() does.
- property stem#
The final path component, minus its last suffix.
- property suffix#
The final component’s last suffix, if any.
This includes the leading period. For example: ‘.txt’
- property suffixes#
A list of the final component’s suffixes, if any.
These include the leading periods. For example: [‘.tar’, ‘.gz’]
- symlink_to(target, target_is_directory=False)[source]#
Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
- touch(mode=438, exist_ok=True)[source]#
Create this file with the given access mode, if it doesn’t exist.
- unlink(missing_ok=False)[source]#
Remove this file or link. If the path is a directory, use rmdir() instead.
- with_name(name)#
Return a new path with the file name changed.
- with_stem(stem)#
Return a new path with the stem changed.
- with_suffix(suffix)#
Return a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.