panpath.local_path
panpath.local_path.LocalPath(*args, **kwargs)
Local filesystem path (drop-in replacement for pathlib.Path).
Inherits from the platform-specific concrete path class (PosixPath/WindowsPath) and PanPath for full compatibility. The concrete class must come first in MRO to ensure proper flavour attribute inheritance in Python 3.10. Includes both sync methods (from Path) and async methods with a prefix.
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 thecomponents 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.
This includes the leading period. For example: '.txt' </>suffixes— A list of the final component's suffixes, if any.
These include the leading periods. For example: ['.tar', '.gz'] </>
__bytes__()— Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>__new__(cls,*args,**kwargs)(PanPath) — Create and return the appropriate path instance.</>__str__()— Return the string representation of the path, suitable forpassing to system calls. </>a_copy(target,follow_symlinks)(PanPath) — Copy file to target.</>a_copytree(target,follow_symlinks)(PanPath) — Recursively copy the directory and all its contents to the target path.</>a_exists()(bool) — Check if path exists (async).</>a_glob(pattern)(AsyncGenerator) — Asynchronously yield paths matching the glob pattern.</>a_is_dir()(bool) — Check if path is a directory (async).</>a_is_file()(bool) — Check if path is a file (async).</>a_is_symlink()(bool) — Check if path is a symlink (async).</>a_iterdir()(AsyncGenerator) — List directory contents (async).</>a_mkdir(mode,parents,exist_ok)— Create directory (async).</>a_open(mode,buffering,encoding,errors,newline)(Any) — Open file and return async file handle.</>a_read_bytes()(bytes) — Read file as bytes (async).</>a_read_text(encoding)(str) — Read file as text (async).</>a_readlink()(LocalPath) — Asynchronously read the target of a symbolic link.</>a_rename(target)(PanPath) — Rename the file or directory to target.</>a_replace(target)(PanPath) — Rename the file or directory to target, overwriting if target exists.</>a_resolve()(PanPath) — Resolve to absolute path (no-op for cloud paths).</>a_rglob(pattern)(AsyncGenerator) — Recursively yield all existing files matching the given pattern.</>a_rmdir()— Remove empty directory (async).</>a_rmtree()— Recursively remove directory and its contents (async).</>a_stat(follow_symlinks)(stat_result) — Get file stats (async).</>a_symlink_to(target,target_is_directory)— Asynchronously create a symbolic link pointing to target.</>a_touch(mode,exist_ok)— Create the file if it does not exist or update the modification time (async).</>a_unlink(missing_ok)— Delete file (async).</>a_walk()(AsyncGenerator) — Asynchronously walk the directory tree.</>a_write_bytes(data)(int) — Write bytes to file (async).</>a_write_text(data,encoding)(int) — Write text to file (async).</>absolute()— Return an absolute version of this path by prepending the currentworking directory. 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 'file' URI.</>chmod(mode,follow_symlinks)— Change the permissions of the path, like os.chmod().</>copy(target,follow_symlinks)(PanPath) — Copy file to target.</>copytree(target,follow_symlinks)(PanPath) — Recursively copy the directory and all its contents to the target path.</>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) </>glob(pattern,case_sensitive)— Iterate over this subtree and yield all existing files (of anykind, including directories) matching the given relative pattern. </>group()— 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 the user's home directory (asreturned by os.path.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()— 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 pointingto 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 reservedby 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 anew 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'spermissions are changed, rather than its target's. </>lstat()— Like stat(), except if the path points to a symlink, the symlink'sstatus 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,newline)— Open the file pointed to by this path and return a file object, asthe built-in open() function does. </>owner()— 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)— 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 passedarguments. If the operation is not possible (because this is not related to the other path), raise ValueError. </>rename(target)(PanPath) — Rename the file or directory to target.</>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 alsonormalizing it. </>rglob(pattern,case_sensitive)— Recursively yield all existing files (of any kind, includingdirectories) matching the given relative pattern, anywhere in this subtree. </>rmdir()— Remove empty directory.</>rmtree()— Recursively remove directory and its contents.</>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, likeos.stat() does. </>symlink_to(target,target_is_directory)— 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,exist_ok)— Create this file with the given access mode, if it doesn't exist.</>unlink(missing_ok)— Remove this file or link.If the path is a directory, use rmdir() instead. </>walk(*args,**kwargs)(Iterator) — Walk the directory tree.</>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 likeiterdir(). </>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 pathhas 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,errors,newline)— Open the file in text mode, write to it, and close the file.</>
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_suffix(suffix)
Return a new path with the file suffix changed. If the pathhas no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.
relative_to(other, *_deprecated, walk_up=False)
Return the relative path to another path identified by the passedarguments. 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.
is_relative_to(other, *_deprecated)
Return True if the path is relative to another path or False.
is_absolute()
True if the path is absolute (has both a root and, if applicable,a drive).
is_reserved()
Return True if the path contains one of the special names reservedby the system, if any.
is_symlink()
Whether this path is a symbolic link.
is_junction()
Whether this path is a junction.
is_block_device()
Whether this path is a block device.
is_char_device()
Whether this path is a character device.
read_bytes()
Open the file in bytes mode, read it, and close the file.
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.
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.
symlink_to(target, target_is_directory=False)
Make this path a symlink pointing to the target path.Note the order of arguments (link, target) is the reverse of os.symlink.
hardlink_to(target)
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.
expanduser()
Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser)
a_touch(mode=438, exist_ok=True)
Create the file if it does not exist or update the modification time (async).
mode(int, optional) — File mode (permissions) to set if creating the file.exist_ok(bool, optional) — If False, raises an error if the file already exists.
a_copytree(target, follow_symlinks=True)
Recursively copy the directory and all its contents to the target path.
target(Union) — Destination PanPath to copy to.follow_symlinks(bool, optional) — If True, copies the contents of symlinks.
The copied PanPath instance.
a_walk()
Asynchronously walk the directory tree.
A list of tuples (dirpath, dirnames, filenames)
a_symlink_to(target, target_is_directory=False)
Asynchronously create a symbolic link pointing to target.
target(Union) — The target path the symbolic link points to.target_is_directory(bool, optional) — Whether the target is a directory.
a_glob(pattern)
Asynchronously yield paths matching the glob pattern.
pattern(str) — Glob pattern (relative)
Matching LocalPath instances
a_rglob(pattern)
Recursively yield all existing files matching the given pattern.
pattern(str) — Glob pattern (relative)
Matching LocalPath instances
a_exists() → bool
Check if path exists (async).
a_is_file() → bool
Check if path is a file (async).
a_is_dir() → bool
Check if path is a directory (async).
a_read_bytes() → bytes
Read file as bytes (async).
a_read_text(encoding='utf-8') → str
Read file as text (async).
encoding(str, optional) — Text encoding to use (default: 'utf-8')
a_write_bytes(data) → int
Write bytes to file (async).
data(bytes) — Bytes to write to the file.
a_write_text(data, encoding='utf-8') → int
Write text to file (async).
data(str) — Text to write to the file.encoding(str, optional) — Text encoding to use (default: 'utf-8')
a_is_symlink() → bool
Check if path is a symlink (async).
a_unlink(missing_ok=False)
Delete file (async).
missing_ok(bool, optional) — If True, does not raise an error if the file does not exist.
a_mkdir(mode=511, parents=False, exist_ok=False)
Create directory (async).
mode(int, optional) — Directory mode (permissions) to set.parents(bool, optional) — If True, create parent directories as needed.exist_ok(bool, optional) — If True, does not raise an error if the directory already exists.
a_rmdir()
Remove empty directory (async).
a_rmtree()
Recursively remove directory and its contents (async).
a_iterdir() → AsyncGenerator
List directory contents (async).
a_stat(follow_symlinks=True) → stat_result
Get file stats (async).
a_open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)
Open file and return async file handle.
mode(str, optional) — Mode to open the file (e.g., 'r', 'rb', 'w', 'wb').encoding(Optional, optional) — Text encoding to use (default: 'utf-8').
Async file handle from aiofiles
copytree(target, follow_symlinks=True)
Recursively copy the directory and all its contents to the target path.
target(Union) — Destination PanPath to copy to.follow_symlinks(bool, optional) — If True, copies the contents of symlinks.
The copied PanPath instance.
rmdir()
Remove empty directory.
rmtree()
Recursively remove directory and its contents.
walk(*args, **kwargs)
Walk the directory tree.
A list of tuples (dirpath, dirnames, filenames)