mutapath.MutaPath

class mutapath.MutaPath(contained: Union[mutapath.mutapath.MutaPath, mutapath.immutapath.Path, path.Path, pathlib.PurePath, str] = '', *, posix: Optional[bool] = None, string_repr: Optional[bool] = None)[source]

Bases: mutapath.immutapath.Path

Mutable Path

__init__(contained: Union[mutapath.mutapath.MutaPath, mutapath.immutapath.Path, path.Path, pathlib.PurePath, str] = '', *, posix: Optional[bool] = None, string_repr: Optional[bool] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

absolute()

Return an absolute version of this path.

abspath()

Return an absolute path.

access(mode)

Return True if current user has access to this path.

as_posix()

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

as_uri()

Return the path as a ‘file’ URI.

basename()

capitalize()

Return a capitalized version of the string.

casefold()

Return a version of the string suitable for caseless comparisons.

cd()

Change the current working directory to the specified path.

center(width[, fillchar])

Return a centered string of length width.

chdir()

Change the current working directory to the specified path.

chmod(mode)

Set the mode.

chown([uid, gid])

Change the owner and group by names rather than the uid or gid numbers.

chroot()

Change root directory to path.

chunks(size, *args, **kwargs)

Returns a generator yielding chunks of the file, so it can

clone(contained)

Clone this path with a new given wrapped path representation, having the same remaining attributes.

copy(dst, *[, follow_symlinks])

Copy data and mode bits (“cp src dst”).

copy2(dst, *[, follow_symlinks])

Copy data and metadata.

copyfile(dst, *[, follow_symlinks])

Copy data from src to dst in the most efficient way possible.

copying([lock, timeout, method])

Create a copying context for this immutable path.

copymode(dst, *[, follow_symlinks])

Copy mode bits from src to dst.

copystat(dst, *[, follow_symlinks])

Copy file metadata

copytree(dst[, symlinks, ignore, …])

Recursively copy a directory tree and return the destination directory.

count(sub[, start[, end]])

Return the number of non-overlapping occurrences of substring sub in string S[start:end].

dirs()

The elements of the list are Path objects.

encode([encoding, errors])

Encode the string using the codec registered for encoding.

endswith(suffix[, start[, end]])

Return True if S ends with the specified suffix, False otherwise.

exists()

Test whether a path exists.

expand()

Clean up a filename by calling expandvars(), expanduser(), and normpath() on it.

expandtabs([tabsize])

Return a copy where all tab characters are expanded using spaces.

expanduser()

Expand ~ and ~user constructions.

expandvars()

Expand shell variables of form $var and ${var}.

files()

The elements of the list are Path objects.

find(sub[, start[, end]])

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

fnmatch(pattern[, normcase])

Return True if self.name matches the given pattern.

format(*args, **kwargs)

Return a formatted version of S, using substitutions from args and kwargs.

format_map(mapping)

Return a formatted version of S, using substitutions from mapping.

get_owner()

Return the name of the owner of this file or directory.

getatime()

getctime()

getcwd()

See also

pathlib.Path.cwd()

getmtime()

getsize()

glob(pattern)

group()

Return the group name of the file gid.

iglob(pattern)

Return an iterator of Path objects that match the pattern.

in_place([mode, buffering, encoding, …])

A context in which a file may be re-written in-place with new content.

index(sub[, start[, end]])

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

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

Whether this path is a directory.

is_fifo()

Whether this path is a FIFO.

is_file()

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

is_mount()

Check if this path is a POSIX mount point

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.

isabs()

Test whether a path is absolute

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

isdecimal()

Return True if the string is a decimal string, False otherwise.

isdigit()

Return True if the string is a digit string, False otherwise.

isdir()

Return true if the pathname refers to an existing directory.

isfile()

Test whether a path is a regular file

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

islink()

Test whether a path is a symbolic link

islower()

Return True if the string is a lowercase string, False otherwise.

ismount()

Test whether a path is a mount point

isnumeric()

Return True if the string is a numeric string, False otherwise.

isprintable()

Return True if the string is printable, False otherwise.

isspace()

Return True if the string is a whitespace string, False otherwise.

istitle()

Return True if the string is a title-cased string, False otherwise.

isupper()

Return True if the string is an uppercase string, False otherwise.

iterdir()

Iterate over the files in this directory.

join(iterable, /)

Concatenate any number of strings.

joinpath(*others)

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

lchmod(mode)

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

lines([encoding, errors, retain])

Open this file, read all lines, return them in a list.

link(newpath)

Create a hard link at newpath, pointing to this file.

link_to(target)

Create a hard link pointing to a path named target.

listdir()

Use files() or dirs() instead if you want a listing of just files or just subdirectories.

ljust(width[, fillchar])

Return a left-justified string of length width.

lower()

Return a copy of the string converted to lowercase.

lstat()

Like stat(), but do not follow symbolic links.

lstrip([chars])

Return a copy of the string with leading whitespace removed.

makedirs(name [[, mode, exist_ok])

Super-mkdir; create a leaf directory and all intermediate ones.

makedirs_p([mode])

Like makedirs(), but does not raise an exception if the directory already exists.

match(path_pattern)

Return True if this path matches the given pattern.

merge_tree(other, *args, **kwargs)

Move, merge and mutate this path to the given other path.

mkdir([mode])

Create a directory.

mkdir_p([mode])

Like mkdir(), but does not raise an exception if the directory already exists.

move(dst[, copy_function])

Recursively move a file or directory to another location.

moving([lock, timeout, method])

Create a moving context for this immutable path.

mutate()

Create a mutable context for this immutable path.

normcase()

Normalize case of pathname.

normpath()

Normalize path, eliminating double slashes, etc.

open(*args, **kwargs)

Open file and return a stream.

partition(sep, /)

Partition the string into three parts using the given separator.

pathconf(name)

Return the configuration limit name for the file or directory path.

posix_string()

Get this path as string with posix-like separators (i.e., ‘/’).

read_bytes()

Return the contents of this file as bytes.

read_hash(hash_name)

Calculate given hash for this file.

read_hexhash(hash_name)

Calculate given hash for this file, returning hexdigest.

read_md5()

Calculate the md5 hash for this file.

read_text([encoding, errors])

Open this file, read it in, return the content as a string.

readlink()

Return the path to which this symbolic link points.

readlinkabs()

Return the path to which this symbolic link points.

realpath()

Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path.

relative_to(*other)

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

relpath([start])

Return this path as a relative path, based from start, which defaults to the current working directory.

relpathto(dest)

Return a relative path from self to dest.

remove()

Remove a file (same as unlink()).

remove_p()

Like remove(), but does not raise an exception if the file does not exist.

removedirs(name)

Super-rmdir; remove a leaf directory and all empty intermediate ones.

removedirs_p()

Like removedirs(), but does not raise an exception if the directory is not empty or does not exist.

rename(new)

Rename a file or directory.

renames(old, new)

Super-rename; create directories as necessary and delete any left empty.

renaming([lock, timeout, method])

Create a renaming context for this immutable path.

replace(old, new[, count])

Return a copy with all occurrences of substring old replaced by new.

resolve([strict])

Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).

rfind(sub[, start[, end]])

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

rglob(pattern)

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

rindex(sub[, start[, end]])

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

rjust(width[, fillchar])

Return a right-justified string of length width.

rmdir()

Remove a directory.

rmdir_p()

Like rmdir(), but does not raise an exception if the directory is not empty or does not exist.

rmtree([ignore_errors, onerror])

Recursively delete a directory tree.

rmtree_p()

Like rmtree(), but does not raise an exception if the directory does not exist.

rpartition(sep, /)

Partition the string into three parts using the given separator.

rsplit([sep, maxsplit])

Return a list of the words in the string, using sep as the delimiter string.

rstrip([chars])

Return a copy of the string with trailing whitespace removed.

samefile(other)

Test whether two pathnames reference the same actual file or directory

split([sep, maxsplit])

Return a list of the words in the string, using sep as the delimiter string.

splitall()

Return a list of the path components in this path.

splitdrive()

Split the drive specifier from this path.

splitext()

Split the filename extension from this path and return the two parts.

splitlines([keepends])

Return a list of the lines in the string, breaking at line boundaries.

splitpath()

splitunc()

See also

os.path.splitunc()

startfile()

Open this path in a platform-dependant manner.

startswith(prefix[, start[, end]])

Return True if S starts with the specified prefix, False otherwise.

stat()

Perform a stat() system call on this path.

statvfs()

Perform a statvfs() system call on this path.

strip([chars])

Return a copy of the string with leading and trailing whitespace removed.

stripext()

For example, Path('/home/guido/python.tar.gz').stripext() returns Path('/home/guido/python.tar').

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

symlink([newlink])

Create a symbolic link at newlink, pointing here.

symlink_to(target[, target_is_directory])

Make this path a symlink pointing to the given path.

title()

Return a version of the string where each word is titlecased.

touch()

Set the access/modified times of this file to the current time.

translate(table, /)

Replace each character in the string using the given translation table.

unlink()

Remove a file (same as remove()).

unlink_p()

Like unlink(), but does not raise an exception if the file does not exist.

upper()

Return a copy of the string converted to uppercase.

using_module(module)

utime(times)

Set the access and modified times of this file.

walk()

The iterator yields Path objects naming each child item of this directory and its descendants.

walkdirs()

walkfiles()

with_base(base[, strip_length])

Clone this path with a new base.

with_name(new_name)

See also

pathlib.PurePath.with_name()

with_parent(new_parent)

Clone this path with a new parent.

with_poxis_enabled([enable])

Clone this path in posix format with posix-like separators (i.e., ‘/’).

with_stem(new_stem)

Clone this path with a new stem.

with_string_repr_enabled([enable])

Clone this path in with string representation enabled.

with_suffix(suffix)

Return a new path with the file suffix changed (or added, if none)

write_bytes(bytes[, append])

Open this file and write the given bytes to it.

write_lines(lines[, encoding, errors, …])

Write the given lines of text to this file.

write_text(text[, encoding, errors, …])

Write the given text to this file.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

Attributes

anchor

The concatenation of the drive and root, or ‘’.

atime

Last access time of the file.

base

Get the path base (i.e., the parent of the file).

bytes

Read the file as bytes stream and return its content.

ctime

Creation time of the file.

cwd

Return a new path pointing to the current working directory (as returned by os.getcwd()).

dirname

Returns the directory component of a pathname

drive

The drive specifier, for example 'C:'.

ext

The file extension, for example '.py'.

home

Get the home path of the current path representation.

lock

Generate a cached file locker for this file with the additional suffix ‘.lock’.

mtime

Last-modified time of the file.

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.

posix_enabled

If set to True, the the representation of this path will always follow the posix format, even on NT filesystems.

root

The root of the path, if any.

size

Size of the file, in bytes.

stem

The final path component, minus its last suffix.

string_repr_enabled

If set to True, the the representation of this path will always be returned unwrapped as the path’s string.

suffix

The final component’s last suffix, if any.

suffixes

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

text

Read the file as text stream and return its content.

to_pathlib

Return the contained path as pathlib.Path representation.