aspsim.configutil.Path

class aspsim.configutil.Path(*args, **kwargs)

Bases: PathBase, 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.

__init__(*args, **kwargs)

Methods

__init__(*args, **kwargs)

absolute()

Return an absolute version of this path No normalization or symlink resolution is performed.

as_posix()

Return the string representation of the path with forward (/) slashes.

as_uri()

Return the path as a URI.

chmod(mode, *[, follow_symlinks])

Change the permissions of the path, like os.chmod().

cwd()

Return a new path pointing to the current working directory.

exists(*[, follow_symlinks])

Whether this path exists.

expanduser()

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

from_uri(uri)

Return a new path from the given 'file' URI.

full_match(pattern, *[, case_sensitive])

Return True if this path matches the given glob-style pattern.

glob(pattern, *[, case_sensitive, ...])

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

group(*[, follow_symlinks])

Return the group name of the file gid.

hardlink_to(target)

Make this path a hard link pointing to the same file as target.

home()

Return a new path pointing to expanduser('~').

is_absolute()

True if the path is absolute (has both a root and, if applicable, a drive).

is_block_device()

Whether this path is a block device.

is_char_device()

Whether this path is a character device.

is_dir(*[, follow_symlinks])

Whether this path is a directory.

is_fifo()

Whether this path is a FIFO.

is_file(*[, follow_symlinks])

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_junction()

Whether this path is a junction.

is_mount()

Check if this path is a mount point

is_relative_to(other, /, *_deprecated)

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.

is_socket()

Whether this path is a socket.

is_symlink()

Whether this path is a symbolic link.

iterdir()

Yield path objects of the directory contents.

joinpath(*pathsegments)

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)

Like chmod(), except if the path points to a symlink, the symlink's permissions are changed, rather than its target's.

lstat()

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, *[, case_sensitive])

Return True if this path matches the given pattern.

mkdir([mode, parents, exist_ok])

Create a new directory at this given path.

open([mode, buffering, encoding, errors, ...])

Open the file pointed to by this path and return a file object, as the built-in open() function does.

owner(*[, follow_symlinks])

Return the login name of the file owner.

read_bytes()

Open the file in bytes mode, read it, and close the file.

read_text([encoding, errors, newline])

Open the file in text mode, read it, and close the file.

readlink()

Return the path to which the symbolic link points.

relative_to(other, /, *_deprecated[, walk_up])

Return the relative path to another path identified by the passed arguments.

rename(target)

Rename this path to the target path.

replace(target)

Rename this path to the target path, overwriting if that path exists.

resolve([strict])

Make the path absolute, resolving all symlinks on the way and also normalizing it.

rglob(pattern, *[, case_sensitive, ...])

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

rmdir()

Remove this directory.

samefile(other_path)

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

stat(*[, follow_symlinks])

Return the result of the stat() system call on this path, like os.stat() does.

symlink_to(target[, target_is_directory])

Make this path a symlink pointing to the target path.

touch([mode, exist_ok])

Create this file with the given access mode, if it doesn't exist.

unlink([missing_ok])

Remove this file or link.

walk([top_down, on_error, follow_symlinks])

Walk the directory tree from this directory, similar to os.walk().

with_name(name)

Return a new path with the file name changed.

with_segments(*pathsegments)

Construct a new path object from any number of path-like objects.

with_stem(stem)

Return a new path with the stem changed.

with_suffix(suffix)

Return a new path with the file suffix changed.

write_bytes(data)

Open the file in bytes mode, write to it, and close the file.

write_text(data[, encoding, errors, newline])

Open the file in text mode, write to it, and close the file.

Attributes

anchor

The concatenation of the drive and root, or ''.

drive

The drive prefix (letter or UNC path), if any.

name

The final path component, if any.

parent

The logical parent of the path.

parents

A sequence of this path's logical parents.

parts

An object providing sequence-like access to the components in the filesystem path.

root

The root of the path, if any.

stem

The final path component, minus its last suffix.

suffix

The final component's last suffix, if any.

suffixes

A list of the final component's suffixes, if any.

absolute()

Return an absolute version of this path No normalization or symlink resolution is performed.

Use resolve() to resolve symlinks and remove ‘..’ segments.

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 URI.

chmod(mode, *, follow_symlinks=True)

Change the permissions of the path, like os.chmod().

classmethod cwd()

Return a new path pointing to the current working directory.

property drive

The drive prefix (letter or UNC path), if any.

exists(*, follow_symlinks=True)

Whether this path exists.

This method normally follows symlinks; to check whether a symlink exists, add the argument follow_symlinks=False.

expanduser()

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

classmethod from_uri(uri)

Return a new path from the given ‘file’ URI.

full_match(pattern, *, case_sensitive=None)

Return True if this path matches the given glob-style pattern. The pattern is matched against the entire path.

glob(pattern, *, case_sensitive=None, recurse_symlinks=False)

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

group(*, follow_symlinks=True)

Return the group name of the file gid.

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()

Return a new path pointing to expanduser(‘~’).

is_absolute()

True if the path is absolute (has both a root and, if applicable, a drive).

is_block_device()

Whether this path is a block device.

is_char_device()

Whether this path is a character device.

is_dir(*, follow_symlinks=True)

Whether this path is a directory.

is_fifo()

Whether this path is a FIFO.

is_file(*, follow_symlinks=True)

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_junction()

Whether this path is a junction.

is_mount()

Check if this path is a mount point

is_relative_to(other, /, *_deprecated)

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.

is_socket()

Whether this path is a socket.

Whether this path is a symbolic link.

iterdir()

Yield path objects of the directory contents.

The children are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.

joinpath(*pathsegments)

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)

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

lstat()

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, *, case_sensitive=None)

Return True if this path matches the given pattern. If the pattern is relative, matching is done from the right; otherwise, the entire path is matched. The recursive wildcard ‘**’ is not supported by this method.

mkdir(mode=511, parents=False, exist_ok=False)

Create a new directory at this given path.

property name

The final path component, if any.

open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)

Open the file pointed to by this path and return a file object, as the built-in open() function does.

owner(*, follow_symlinks=True)

Return the login name of the file owner.

property parent

The logical parent of the path.

property parents

A sequence of this path’s logical parents.

parser = <module 'posixpath' (frozen)>
property parts

An object providing sequence-like access to the components in the filesystem path.

read_bytes()

Open the file in bytes mode, read it, and close the file.

read_text(encoding=None, errors=None, newline=None)

Open the file in text mode, read it, and close the file.

Return the path to which the symbolic link points.

relative_to(other, /, *_deprecated, walk_up=False)

Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not related to the other path), raise ValueError.

The walk_up parameter controls whether .. may be used to resolve the path.

rename(target)

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)

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)

Make the path absolute, resolving all symlinks on the way and also normalizing it.

rglob(pattern, *, case_sensitive=None, recurse_symlinks=False)

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

rmdir()

Remove this directory. The directory must be empty.

property root

The root of the path, if any.

samefile(other_path)

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

stat(*, follow_symlinks=True)

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’]

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)

Create this file with the given access mode, if it doesn’t exist.

Remove this file or link. If the path is a directory, use rmdir() instead.

walk(top_down=True, on_error=None, follow_symlinks=False)

Walk the directory tree from this directory, similar to os.walk().

with_name(name)

Return a new path with the file name changed.

with_segments(*pathsegments)

Construct a new path object from any number of path-like objects. Subclasses may override this method to customize how new path objects are created from methods like iterdir().

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.

write_bytes(data)

Open the file in bytes mode, write to it, and close the file.

write_text(data, encoding=None, errors=None, newline=None)

Open the file in text mode, write to it, and close the file.