Skip to content

xqute.path

module

xqute.path

Provides the SpecPath and MountedPath classes.

It is used to represent paths of jobs and it is useful when a job is running in a remote system (a VM, a container, etc.), where we need to mount the paths into the remote system (MountedPath).

But in the system where this framework is running, we need to use the paths (specified directly) that are used in the framework, where we also need to carry the information of the mounted path (SpecPath).

The module provides two main abstract base classes:

  • - MountedPath: Represents a path as it appears in the remote execution environment.
  • - SpecPath: Represents a path as it appears in the local environment where the
framework runs.

Both classes have implementations for local paths and various cloud storage paths, including:

  • - Google Cloud Storage
  • - Azure Blob Storage
  • - Amazon S3

These classes maintain the relationship between the local and remote pathrepresentations, allowing transparent path operations while preserving both path contexts.

Classes
  • MountedPath (MountedPath) A router class to instantiate the correct path based on the path typefor the mounted path. </>
  • MountedLocalPath (MountedPath) A class to represent a mounted local path</>
  • MountedCloudPath(path, spec, *args, **kwargs) (MountedPath) A class to represent a mounted cloud path</>
  • MountedGSPath (MountedPath) A class to represent a mounted Google Cloud Storage path</>
  • MountedAzurePath (MountedPath) A class to represent a mounted Azure Blob Storage path</>
  • MountedS3Path (MountedPath) A class to represent a mounted Amazon S3 path</>
  • SpecPath (xqute.path.speclocalpath | xqute.path.speccloudpath) A router class to instantiate the correct path based on the path typefor the spec path. </>
  • SpecLocalPath (xqute.path.speclocalpath | xqute.path.speccloudpath) A class to represent a spec local path</>
  • SpecCloudPath(path, *args, mounted, **kwargs) (xqute.path.speclocalpath | xqute.path.speccloudpath) A class to represent a spec cloud path</>
  • SpecGSPath (xqute.path.speclocalpath | xqute.path.speccloudpath) A class to represent a spec Google Cloud Storage path</>
  • SpecAzurePath (xqute.path.speclocalpath | xqute.path.speccloudpath) A class to represent a spec Azure Blob Storage path</>
  • SpecS3Path (xqute.path.speclocalpath | xqute.path.speccloudpath) A class to represent a spec Amazon S3 path</>
class

xqute.path.MountedPath(path, spec=None, *args, **kwargs)MountedPath

Bases
panpath.base.PanPath pathlib.Path pathlib.PurePath

A router class to instantiate the correct path based on the path typefor the mounted path.

This abstract base class serves as a factory that creates appropriate mounted path instances based on the input path type. It represents a path as it exists in a remote execution environment (e.g., container, VM) while maintaining a reference to the corresponding path in the local environment.

Attributes
  • _spec The corresponding path in the local environment (SpecPath).
  • 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 Get the parent directory of this 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.</>
  • spec Get the corresponding spec path in the local environment.</>
  • 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'] </>
Examples
>>> # Create a mounted path with corresponding spec path>>> mounted_path = MountedPath(
>>>   "/container/data/file.txt", spec="/local/data/file.txt"
>>> )
>>> str(mounted_path)
'/container/data/file.txt'
>>> str(mounted_path.spec)
'/local/data/file.txt'
>>> # Create a GCS mounted path
>>> gs_path = MountedPath("gs://bucket/file.txt", spec="/local/file.txt")
>>> type(gs_path)
<class 'xqute.path.MountedGSPath'>
>>> # Serialize and deserialize a mounted path
>>> import pickle
>>> mounted_path = MountedPath("/container/data/file.txt",
...                            spec="/local/data/file.txt")
>>> serialized = pickle.dumps(mounted_path)
>>> restored = pickle.loads(serialized)
>>> str(restored) == str(mounted_path)
True
>>> str(restored.spec) == str(mounted_path.spec)
True
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __hash__() (int) Generate a hash for the MountedPath.</>
  • __new__(cls, path, spec, *args, **kwargs) (An instance of the appropriate MountedPath subclass based on the path type) Factory method to create the appropriate MountedPath subclass instance.</>
  • __reduce__() Support for pickling and serialization.</>
  • __repr__() (str) Generate a string representation of the MountedPath.</>
  • __setstate__(state) Restore internal state after unpickling.</>
  • __str__() Return the string representation of the path, suitable forpassing to system calls. </>
  • __truediv__(key) (MountedPath) Implement the / operator for paths.</>
  • a_copy(target) (PanPath) Asynchronously copy this path to the target path.</>
  • a_copytree(target, follow_symlinks) (PanPath) Asynchronously copy the directory and all its contents recursively to the target path.</>
  • a_exists() (bool) Asynchronously check if the path exists.</>
  • a_glob(pattern) (AsyncGenerator) Asynchronously yield paths matching a glob pattern.</>
  • a_is_dir() (bool) Asynchronously check if the path is a directory.</>
  • a_is_file() (bool) Asynchronously check if the path is a file.</>
  • a_is_symlink() (bool) Asynchronously check if the path is a symbolic link.</>
  • a_iterdir() (AsyncGenerator) Asynchronously iterate over directory contents.</>
  • a_mkdir(mode, parents, exist_ok) Asynchronously create a directory at this path.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Asynchronously open the file and return an async file handle.</>
  • a_read_bytes() (bytes) Asynchronously read the file's bytes.</>
  • a_read_text(encoding) (str) Asynchronously read the file's text content.</>
  • a_readlink() (PanPath) Asynchronously read the target of the symbolic link.</>
  • a_rename(target) (PanPath) Asynchronously rename this path to the target path.</>
  • a_replace(target) (PanPath) Asynchronously replace this path with the target path.</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Asynchronously yield paths matching a recursive glob pattern.</>
  • a_rmdir() Asynchronously remove the directory and its contents recursively.</>
  • a_rmtree(ignore_errors, onerror) Asynchronously remove the directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (stat_result) Asynchronously get the file or directory's status information.</>
  • a_symlink_to(target, target_is_directory) Asynchronously create a symbolic link pointing to the target path.</>
  • a_touch(mode, exist_ok) Asynchronously create the file if it does not exist.</>
  • a_unlink(missing_ok) Asynchronously remove (delete) the file or empty directory.</>
  • a_walk() (AsyncGenerator) Asynchronously walk the directory tree.</>
  • a_write_bytes(data) (Optional) Asynchronously write bytes to the file.</>
  • a_write_text(data, encoding) (int) Asynchronously write text to the file.</>
  • 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().</>
  • 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) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • 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_mounted() (bool) Check if this path is actually mounted (different from spec path).</>
  • 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) (MountedPath) Join path components to this path.</>
  • 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) 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 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 this directory. The directory must be empty.</>
  • 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() Walk the directory tree.</>
  • with_name(name) (MountedPath) Return a new path with the 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) (MountedPath) Return a new path with the 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.</>
method

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

method

__str__()

Return the string representation of the path, suitable forpassing to system calls.

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

as_uri()

Return the path as a 'file' URI.

method

with_stem(stem)

Return a new path with the stem changed.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_absolute()

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

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

match(path_pattern, case_sensitive=None)

Return True if this path matches the given pattern.

method

stat(follow_symlinks=True)

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

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

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.

method

is_dir()

Whether this path is a directory.

method

is_file()

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

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

method

samefile(other_path)

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

method

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

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

method

read_bytes()

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

method

read_text(encoding=None, errors=None)

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

method

write_bytes(data)

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

method

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

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

generator

iterdir()

Yield path objects of the directory contents.

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

generator

glob(pattern, case_sensitive=None)

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

generator

rglob(pattern, case_sensitive=None)

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

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

absolute()

Return an absolute version of this path by prepending the currentworking directory. No normalization or symlink resolution is performed.

Use resolve() to get the canonical path to a file.

method

resolve(strict=False)

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

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

touch(mode=438, exist_ok=True)

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

method

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

Create a new directory at this given path.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

rmdir()

Remove this directory. The directory must be empty.

method

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.

method

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.

method

expanduser()

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

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_exists()

Asynchronously check if the path exists.

Returns (bool)

True if the path exists, False otherwise.

method

a_read_bytes()

Asynchronously read the file's bytes.

Returns (bytes)

File content as bytes.

method

a_read_text(encoding='utf-8')

Asynchronously read the file's text content.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
Returns (str)

File content as string.

method

a_write_bytes(data)

Asynchronously write bytes to the file.

Parameters
  • data (bytes) Bytes to write to the file.
Returns (Optional)

Number of bytes written. For some cloud paths, may return None.

method

a_write_text(data, encoding='utf-8')

Asynchronously write text to the file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
Returns (int)

Number of characters written.

method

a_iterdir()

Asynchronously iterate over directory contents.

Yields (AsyncGenerator)

PanPath instances for each item in the directory.

method

a_is_dir()

Asynchronously check if the path is a directory.

Returns (bool)

True if the path is a directory, False otherwise.

method

a_is_file()

Asynchronously check if the path is a file.

Returns (bool)

True if the path is a file, False otherwise.

method

a_stat(follow_symlinks=True)

Asynchronously get the file or directory's status information.

Returns (stat_result)

An object containing file status information (platform-dependent).

method

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

Asynchronously create a directory at this path.

Parameters
  • 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.
method

a_glob(pattern)

Asynchronously yield paths matching a glob pattern.

Parameters
  • pattern (str) Glob pattern to match.
Returns (AsyncGenerator)

List of PanPath instances matching the pattern.

method

a_rglob(pattern)

Asynchronously yield paths matching a recursive glob pattern.

Parameters
  • pattern (str) Recursive glob pattern to match.
Returns (AsyncGenerator)

List of PanPath instances matching the pattern.

method

a_walk()

Asynchronously walk the directory tree.

Yields (AsyncGenerator)

Tuples of (current_path, dirnames, filenames) at each level.

method

a_touch(mode=438, exist_ok=True)

Asynchronously create the file if it does not exist.

Parameters
  • 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.
method

a_rename(target)

Asynchronously rename this path to the target path.

Parameters
  • target (Union) New path to rename to.
Returns (PanPath)

The renamed PanPath instance.

method

a_replace(target)

Asynchronously replace this path with the target path.

Parameters
  • target (Union) New path to replace with.
Returns (PanPath)

The replaced PanPath instance.

method

a_rmdir()

Asynchronously remove the directory and its contents recursively.

method

a_rmtree(ignore_errors=False, onerror=None)

Asynchronously remove the directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, ignores errors during removal.
  • onerror (Any, optional) Optional function to call on errors.
method

a_copy(target)

Asynchronously copy this path to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
Returns (PanPath)

The copied PanPath instance.

method

a_copytree(target, follow_symlinks=True)

Asynchronously copy the directory and all its contents recursively to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
  • follow_symlinks (bool, optional) If True, copies the contents of symlinks.
Returns (PanPath)

The copied PanPath instance.

method

a_open(mode='r', encoding='utf-8', **kwargs)

Asynchronously open the file and return an async file handle.

Parameters
  • mode (str, optional) Mode to open the file (e.g., 'r', 'rb', 'w', 'wb').
  • encoding (str, optional) Text encoding to use (default: 'utf-8').
  • **kwargs (Any) Additional arguments to pass to the underlying open method.
Returns (AsyncFileHandle)

An async file handle.

method

walk()

Walk the directory tree.

Yields

Tuples of (current_path, dirnames, filenames) at each level.

staticmethod

__new__(cls, path, spec=None, *args, **kwargs)

Factory method to create the appropriate MountedPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the mounted path location.
  • spec (str | pathlib.path | none, optional) The path string or object representing the corresponding spec path.If None, the mounted path itself will be used as the spec path.
Returns (An instance of the appropriate MountedPath subclass based on the path type)

ss s s

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

method

is_mounted()

Check if this path is actually mounted (different from spec path).

Returns (bool)

True if the mounted path is different from the spec path, Falseotherwise.

method

__repr__()

Generate a string representation of the MountedPath.

Returns (str)

A string showing the class name, path, and spec path (if different).

method

__eq__(other)

Check equality with another path object.

Two MountedPath objects are equal if they have the same path string and the same spec path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the MountedPath.

Returns (int)

A hash value based on the path string and spec path string.

method

__reduce__()

Support for pickling and serialization.

Returns a tuple of (callable, args, state) so that the underlying path is reconstructed from its string, and the spec relationship is restored via state.

method

__setstate__(state)

Restore internal state after unpickling.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (MountedPath)

A new mounted path with the name changed in both the mounted path and spec path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (MountedPath)

A new mounted path with the suffix changed in both the mounted path and spec path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (MountedPath)

A new mounted path with the segments appended to both the mounted path and spec path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (MountedPath)

A new mounted path with the segment appended.

class

xqute.path.MountedLocalPath(path, spec=None, *args, **kwargs)MountedPath

Bases
xqute.path.MountedPath panpath.local_path.LocalPath pathlib.PosixPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a mounted local path

This class represents a path in a local filesystem as it appears in a remote execution environment, while maintaining a reference to its corresponding path in the framework's environment.

Attributes
  • _spec The corresponding path in the local environment.
  • 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 Get the parent directory of this 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.</>
  • spec Get the corresponding spec path in the local environment.</>
  • 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'] </>
Examples
>>> mounted_path = MountedLocalPath("/container/data/file.txt",...                               spec="/local/data/file.txt")
>>> str(mounted_path)
'/container/data/file.txt'
>>> str(mounted_path.spec)
'/local/data/file.txt'
>>> mounted_path.name
'file.txt'
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __hash__() (int) Generate a hash for the MountedPath.</>
  • __new__(cls, path, spec, *args, **kwargs) (An instance of the appropriate MountedPath subclass based on the path type) Factory method to create the appropriate MountedPath subclass instance.</>
  • __reduce__() Support for pickling and serialization.</>
  • __repr__() (str) Generate a string representation of the MountedPath.</>
  • __setstate__(state) Restore internal state after unpickling.</>
  • __str__() Return the string representation of the path, suitable forpassing to system calls. </>
  • __truediv__(key) (MountedPath) Implement the / operator for paths.</>
  • 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) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • 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_mounted() (bool) Check if this path is actually mounted (different from spec path).</>
  • 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) (MountedPath) Join path components to this path.</>
  • 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) (MountedPath) Return a new path with the 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) (MountedPath) Return a new path with the 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.</>
method

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

method

__str__()

Return the string representation of the path, suitable forpassing to system calls.

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

as_uri()

Return the path as a 'file' URI.

method

with_stem(stem)

Return a new path with the stem changed.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_absolute()

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

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

match(path_pattern, case_sensitive=None)

Return True if this path matches the given pattern.

method

stat(follow_symlinks=True)

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

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

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.

method

is_dir()

Whether this path is a directory.

method

is_file()

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

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

method

samefile(other_path)

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

method

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

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

method

read_bytes()

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

method

read_text(encoding=None, errors=None)

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

method

write_bytes(data)

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

method

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

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

generator

iterdir()

Yield path objects of the directory contents.

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

generator

glob(pattern, case_sensitive=None)

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

generator

rglob(pattern, case_sensitive=None)

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

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

absolute()

Return an absolute version of this path by prepending the currentworking directory. No normalization or symlink resolution is performed.

Use resolve() to get the canonical path to a file.

method

resolve(strict=False)

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

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

touch(mode=438, exist_ok=True)

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

method

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

Create a new directory at this given path.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

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.

method

expanduser()

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

method

a_touch(mode=438, exist_ok=True)

Create the file if it does not exist or update the modification time (async).

Parameters
  • 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.
method

a_rename(target)

Rename the file or directory to target.

Parameters
  • target (Union) New path
Returns (PanPath)

New path instance

method

a_replace(target)

Rename the file or directory to target, overwriting if target exists.

Parameters
  • target (Union) New path
Returns (PanPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Recursively copy the directory and all its contents to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
  • follow_symlinks (bool, optional) If True, copies the contents of symlinks.
Returns (PanPath)

The copied PanPath instance.

method

a_walk()

Asynchronously walk the directory tree.

Returns (AsyncGenerator)

A list of tuples (dirpath, dirnames, filenames)

method

a_glob(pattern)

Asynchronously yield paths matching the glob pattern.

Parameters
  • pattern (str) Glob pattern (relative)
Yields (AsyncGenerator)

Matching LocalPath instances

method

a_rglob(pattern)

Recursively yield all existing files matching the given pattern.

Parameters
  • pattern (str) Glob pattern (relative)
Yields (AsyncGenerator)

Matching LocalPath instances

method

a_exists() → bool

Check if path exists (async).

method

a_is_file() → bool

Check if path is a file (async).

method

a_is_dir() → bool

Check if path is a directory (async).

method

a_read_bytes() → bytes

Read file as bytes (async).

method

a_read_text(encoding='utf-8') → str

Read file as text (async).

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data) → int

Write bytes to file (async).

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file (async).

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

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

Create directory (async).

Parameters
  • 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.
method

a_rmdir()

Remove empty directory (async).

method

a_rmtree()

Recursively remove directory and its contents (async).

method

a_iterdir() → AsyncGenerator

List directory contents (async).

method

a_stat(follow_symlinks=True) → stat_result

Get file stats (async).

method

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

Open file and return async file handle.

Parameters
  • mode (str, optional) Mode to open the file (e.g., 'r', 'rb', 'w', 'wb').
  • encoding (Optional, optional) Text encoding to use (default: 'utf-8').
Returns (Any)

Async file handle from aiofiles

method

rename(target)

Rename the file or directory to target.

Parameters
  • target (Union) New path
Returns (PanPath)

New path instance

method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If True, follow symbolic links
Returns (PanPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Recursively copy the directory and all its contents to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
  • follow_symlinks (bool, optional) If True, copies the contents of symlinks.
Returns (PanPath)

The copied PanPath instance.

method

rmdir()

Remove empty directory.

method

rmtree()

Recursively remove directory and its contents.

generator

walk(*args, **kwargs)

Walk the directory tree.

Returns (Iterator)

A list of tuples (dirpath, dirnames, filenames)

staticmethod

__new__(cls, path, spec=None, *args, **kwargs)

Factory method to create the appropriate MountedPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the mounted path location.
  • spec (str | pathlib.path | none, optional) The path string or object representing the corresponding spec path.If None, the mounted path itself will be used as the spec path.
Returns (An instance of the appropriate MountedPath subclass based on the path type)

ss s s

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

method

is_mounted()

Check if this path is actually mounted (different from spec path).

Returns (bool)

True if the mounted path is different from the spec path, Falseotherwise.

method

__repr__()

Generate a string representation of the MountedPath.

Returns (str)

A string showing the class name, path, and spec path (if different).

method

__eq__(other)

Check equality with another path object.

Two MountedPath objects are equal if they have the same path string and the same spec path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the MountedPath.

Returns (int)

A hash value based on the path string and spec path string.

method

__reduce__()

Support for pickling and serialization.

Returns a tuple of (callable, args, state) so that the underlying path is reconstructed from its string, and the spec relationship is restored via state.

method

__setstate__(state)

Restore internal state after unpickling.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (MountedPath)

A new mounted path with the name changed in both the mounted path and spec path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (MountedPath)

A new mounted path with the suffix changed in both the mounted path and spec path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (MountedPath)

A new mounted path with the segments appended to both the mounted path and spec path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (MountedPath)

A new mounted path with the segment appended.

abstract class

xqute.path.MountedCloudPath(path, spec=None, *args, **kwargs)MountedPath

Bases
xqute.path.MountedPath panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a mounted cloud path

This class represents a cloud storage path as it appears in a remote execution environment, while maintaining a reference to its corresponding path in the framework's environment.

Attributes
  • _spec The corresponding path in the local environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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.</>
  • spec Get the corresponding spec path in the local environment.</>
  • 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'] </>
Examples
>>> mounted_path = MountedPath("gs://bucket/file.txt",...    spec="gs://local-bucket/file.txt")
>>> str(mounted_path)
'gs://bucket/file.txt'
>>> str(mounted_path.spec)
'gs://local-bucket/file.txt'
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the MountedPath.</>
  • __new__(cls, path, spec, *args, **kwargs) (An instance of the appropriate MountedPath subclass based on the path type) Factory method to create the appropriate MountedPath subclass instance.</>
  • __reduce__() Support for pickling and serialization.</>
  • __repr__() (str) Generate a string representation of the MountedPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __setstate__(state) Restore internal state after unpickling.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (MountedPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • is_junction() Whether this path is a junction.</>
  • is_mount() Check if this path is a mount point</>
  • is_mounted() (bool) Check if this path is actually mounted (different from spec path).</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (MountedPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (MountedPath) Return a new path with the 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) (MountedPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

with_stem(stem)

Return a new path with the stem changed.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

method

a_write_bytes(data)

Write bytes to file.

method

a_write_text(data, encoding='utf-8') → int

Write text to file.

method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, spec=None, *args, **kwargs)

Factory method to create the appropriate MountedPath subclass instance.

Parameters
  • path (str | pathlib.path) The path string or object representing the mounted path location.
  • spec (str | pathlib.path | none, optional) The path string or object representing the corresponding spec path.If None, the mounted path itself will be used as the spec path.
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
Returns (An instance of the appropriate MountedPath subclass based on the path type)

ss s s

method

is_mounted()

Check if this path is actually mounted (different from spec path).

Returns (bool)

True if the mounted path is different from the spec path, Falseotherwise.

method

__repr__()

Generate a string representation of the MountedPath.

Returns (str)

A string showing the class name, path, and spec path (if different).

method

__eq__(other)

Check equality with another path object.

Two MountedPath objects are equal if they have the same path string and the same spec path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the MountedPath.

Returns (int)

A hash value based on the path string and spec path string.

method

__reduce__()

Support for pickling and serialization.

Returns a tuple of (callable, args, state) so that the underlying path is reconstructed from its string, and the spec relationship is restored via state.

method

__setstate__(state)

Restore internal state after unpickling.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (MountedPath)

A new mounted path with the name changed in both the mounted path and spec path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (MountedPath)

A new mounted path with the suffix changed in both the mounted path and spec path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (MountedPath)

A new mounted path with the segments appended to both the mounted path and spec path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (MountedPath)

A new mounted path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

class

xqute.path.MountedGSPath(path, spec=None, *args, **kwargs)MountedPath

Bases
xqute.path.MountedCloudPath xqute.path.MountedPath panpath.gs_path.GSPath panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a mounted Google Cloud Storage path

This class represents a Google Cloud Storage path as it appears in a remote execution environment, while maintaining a reference to its corresponding path in the framework's environment.

Attributes
  • _spec The corresponding path in the local environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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.</>
  • spec Get the corresponding spec path in the local environment.</>
  • 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'] </>
Examples
>>> mounted_path = MountedPath("gs://bucket/file.txt",...                          spec="gs://local-bucket/file.txt")
>>> isinstance(mounted_path, MountedGSPath)
True
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the MountedPath.</>
  • __new__(cls, path, spec, *args, **kwargs) (An instance of the appropriate MountedPath subclass based on the path type) Factory method to create the appropriate MountedPath subclass instance.</>
  • __reduce__() Support for pickling and serialization.</>
  • __repr__() (str) Generate a string representation of the MountedPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __setstate__(state) Restore internal state after unpickling.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (MountedPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • is_junction() Whether this path is a junction.</>
  • is_mount() Check if this path is a mount point</>
  • is_mounted() (bool) Check if this path is actually mounted (different from spec path).</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (MountedPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (MountedPath) Return a new path with the 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) (MountedPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

with_stem(stem)

Return a new path with the stem changed.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data)

Write bytes to file.

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • mode (int, optional) File mode (permissions) to set if creating the file.
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, spec=None, *args, **kwargs)

Factory method to create the appropriate MountedPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the mounted path location.
  • spec (str | pathlib.path | none, optional) The path string or object representing the corresponding spec path.If None, the mounted path itself will be used as the spec path.
Returns (An instance of the appropriate MountedPath subclass based on the path type)

ss s s

method

is_mounted()

Check if this path is actually mounted (different from spec path).

Returns (bool)

True if the mounted path is different from the spec path, Falseotherwise.

method

__repr__()

Generate a string representation of the MountedPath.

Returns (str)

A string showing the class name, path, and spec path (if different).

method

__eq__(other)

Check equality with another path object.

Two MountedPath objects are equal if they have the same path string and the same spec path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the MountedPath.

Returns (int)

A hash value based on the path string and spec path string.

method

__reduce__()

Support for pickling and serialization.

Returns a tuple of (callable, args, state) so that the underlying path is reconstructed from its string, and the spec relationship is restored via state.

method

__setstate__(state)

Restore internal state after unpickling.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (MountedPath)

A new mounted path with the name changed in both the mounted path and spec path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (MountedPath)

A new mounted path with the suffix changed in both the mounted path and spec path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (MountedPath)

A new mounted path with the segments appended to both the mounted path and spec path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (MountedPath)

A new mounted path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

class

xqute.path.MountedAzurePath(path, spec=None, *args, **kwargs)MountedPath

Bases
xqute.path.MountedCloudPath xqute.path.MountedPath panpath.azure_path.AzurePath panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a mounted Azure Blob Storage path

This class represents an Azure Blob Storage path as it appears in a remote execution environment, while maintaining a reference to its corresponding path in the framework's environment.

Attributes
  • _spec The corresponding path in the local environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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.</>
  • spec Get the corresponding spec path in the local environment.</>
  • 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'] </>
Examples
>>> mounted_path = MountedPath("az://container/blob",...                          spec="az://local-container/blob")
>>> isinstance(mounted_path, MountedAzurePath)
True
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the MountedPath.</>
  • __new__(cls, path, spec, *args, **kwargs) (An instance of the appropriate MountedPath subclass based on the path type) Factory method to create the appropriate MountedPath subclass instance.</>
  • __reduce__() Support for pickling and serialization.</>
  • __repr__() (str) Generate a string representation of the MountedPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __setstate__(state) Restore internal state after unpickling.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (MountedPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • is_junction() Whether this path is a junction.</>
  • is_mount() Check if this path is a mount point</>
  • is_mounted() (bool) Check if this path is actually mounted (different from spec path).</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (MountedPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (MountedPath) Return a new path with the 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) (MountedPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

with_stem(stem)

Return a new path with the stem changed.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data)

Write bytes to file.

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • mode (int, optional) File mode (permissions) to set if creating the file.
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, spec=None, *args, **kwargs)

Factory method to create the appropriate MountedPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the mounted path location.
  • spec (str | pathlib.path | none, optional) The path string or object representing the corresponding spec path.If None, the mounted path itself will be used as the spec path.
Returns (An instance of the appropriate MountedPath subclass based on the path type)

ss s s

method

is_mounted()

Check if this path is actually mounted (different from spec path).

Returns (bool)

True if the mounted path is different from the spec path, Falseotherwise.

method

__repr__()

Generate a string representation of the MountedPath.

Returns (str)

A string showing the class name, path, and spec path (if different).

method

__eq__(other)

Check equality with another path object.

Two MountedPath objects are equal if they have the same path string and the same spec path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the MountedPath.

Returns (int)

A hash value based on the path string and spec path string.

method

__reduce__()

Support for pickling and serialization.

Returns a tuple of (callable, args, state) so that the underlying path is reconstructed from its string, and the spec relationship is restored via state.

method

__setstate__(state)

Restore internal state after unpickling.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (MountedPath)

A new mounted path with the name changed in both the mounted path and spec path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (MountedPath)

A new mounted path with the suffix changed in both the mounted path and spec path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (MountedPath)

A new mounted path with the segments appended to both the mounted path and spec path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (MountedPath)

A new mounted path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

class

xqute.path.MountedS3Path(path, spec=None, *args, **kwargs)MountedPath

Bases
xqute.path.MountedCloudPath xqute.path.MountedPath panpath.s3_path.S3Path panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a mounted Amazon S3 path

This class represents an Amazon S3 path as it appears in a remote execution environment, while maintaining a reference to its corresponding path in the framework's environment.

Attributes
  • _spec The corresponding path in the local environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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.</>
  • spec Get the corresponding spec path in the local environment.</>
  • 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'] </>
Examples
>>> mounted_path = MountedPath("s3://bucket/key",...                          spec="s3://local-bucket/key")
>>> isinstance(mounted_path, MountedS3Path)
True
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the MountedPath.</>
  • __new__(cls, path, spec, *args, **kwargs) (An instance of the appropriate MountedPath subclass based on the path type) Factory method to create the appropriate MountedPath subclass instance.</>
  • __reduce__() Support for pickling and serialization.</>
  • __repr__() (str) Generate a string representation of the MountedPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __setstate__(state) Restore internal state after unpickling.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (MountedPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • is_junction() Whether this path is a junction.</>
  • is_mount() Check if this path is a mount point</>
  • is_mounted() (bool) Check if this path is actually mounted (different from spec path).</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (MountedPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (MountedPath) Return a new path with the 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) (MountedPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

with_stem(stem)

Return a new path with the stem changed.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data)

Write bytes to file.

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • mode (int, optional) File mode (permissions) to set if creating the file.
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, spec=None, *args, **kwargs)

Factory method to create the appropriate MountedPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the mounted path location.
  • spec (str | pathlib.path | none, optional) The path string or object representing the corresponding spec path.If None, the mounted path itself will be used as the spec path.
Returns (An instance of the appropriate MountedPath subclass based on the path type)

ss s s

method

is_mounted()

Check if this path is actually mounted (different from spec path).

Returns (bool)

True if the mounted path is different from the spec path, Falseotherwise.

method

__repr__()

Generate a string representation of the MountedPath.

Returns (str)

A string showing the class name, path, and spec path (if different).

method

__eq__(other)

Check equality with another path object.

Two MountedPath objects are equal if they have the same path string and the same spec path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the MountedPath.

Returns (int)

A hash value based on the path string and spec path string.

method

__reduce__()

Support for pickling and serialization.

Returns a tuple of (callable, args, state) so that the underlying path is reconstructed from its string, and the spec relationship is restored via state.

method

__setstate__(state)

Restore internal state after unpickling.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (MountedPath)

A new mounted path with the name changed in both the mounted path and spec path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (MountedPath)

A new mounted path with the suffix changed in both the mounted path and spec path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (MountedPath)

A new mounted path with the segments appended to both the mounted path and spec path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (MountedPath)

A new mounted path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

class

xqute.path.SpecPath(path, *args, mounted=None, **kwargs) → xqute.path.speclocalpath | xqute.path.speccloudpath

Bases
panpath.base.PanPath pathlib.Path pathlib.PurePath

A router class to instantiate the correct path based on the path typefor the spec path.

This abstract base class serves as a factory that creates appropriate spec path instances based on the input path type. It represents a path in the local environment where the framework runs, while maintaining a reference to the corresponding path in the remote execution environment.

Attributes
  • _mounted The corresponding path in the remote execution environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • mounted Get the corresponding mounted path in the remote environment.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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'] </>
Examples
>>> # Create a spec path with corresponding mounted path>>> spec_path = SpecPath(
>>>   "/local/data/file.txt", mounted="/container/data/file.txt"
>>> )
>>> str(spec_path)
'/local/data/file.txt'
>>> str(spec_path.mounted)
'/container/data/file.txt'
>>> # Create a GCS spec path
>>> gs_path = SpecPath(
>>>   "gs://bucket/file.txt", mounted="gs://container-bucket/file.txt"
>>> )
>>> type(gs_path)
<class 'xqute.path.SpecGSPath'>
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __hash__() (int) Generate a hash for the SpecPath.</>
  • __new__(cls, path, *args, mounted, **kwargs) (An instance of the appropriate SpecPath subclass based on the path type) Factory method to create the appropriate SpecPath subclass instance.</>
  • __repr__() (str) Generate a string representation of the SpecPath.</>
  • __str__() Return the string representation of the path, suitable forpassing to system calls. </>
  • __truediv__(key) (SpecPath) Implement the / operator for paths.</>
  • a_copy(target) (PanPath) Asynchronously copy this path to the target path.</>
  • a_copytree(target, follow_symlinks) (PanPath) Asynchronously copy the directory and all its contents recursively to the target path.</>
  • a_exists() (bool) Asynchronously check if the path exists.</>
  • a_glob(pattern) (AsyncGenerator) Asynchronously yield paths matching a glob pattern.</>
  • a_is_dir() (bool) Asynchronously check if the path is a directory.</>
  • a_is_file() (bool) Asynchronously check if the path is a file.</>
  • a_is_symlink() (bool) Asynchronously check if the path is a symbolic link.</>
  • a_iterdir() (AsyncGenerator) Asynchronously iterate over directory contents.</>
  • a_mkdir(mode, parents, exist_ok) Asynchronously create a directory at this path.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Asynchronously open the file and return an async file handle.</>
  • a_read_bytes() (bytes) Asynchronously read the file's bytes.</>
  • a_read_text(encoding) (str) Asynchronously read the file's text content.</>
  • a_readlink() (PanPath) Asynchronously read the target of the symbolic link.</>
  • a_rename(target) (PanPath) Asynchronously rename this path to the target path.</>
  • a_replace(target) (PanPath) Asynchronously replace this path with the target path.</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Asynchronously yield paths matching a recursive glob pattern.</>
  • a_rmdir() Asynchronously remove the directory and its contents recursively.</>
  • a_rmtree(ignore_errors, onerror) Asynchronously remove the directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (stat_result) Asynchronously get the file or directory's status information.</>
  • a_symlink_to(target, target_is_directory) Asynchronously create a symbolic link pointing to the target path.</>
  • a_touch(mode, exist_ok) Asynchronously create the file if it does not exist.</>
  • a_unlink(missing_ok) Asynchronously remove (delete) the file or empty directory.</>
  • a_walk() (AsyncGenerator) Asynchronously walk the directory tree.</>
  • a_write_bytes(data) (Optional) Asynchronously write bytes to the file.</>
  • a_write_text(data, encoding) (int) Asynchronously write text to the file.</>
  • 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().</>
  • 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) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • 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) (SpecPath) Join path components to this path.</>
  • 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) 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 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 this directory. The directory must be empty.</>
  • 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() Walk the directory tree.</>
  • with_name(name) (SpecPath) Return a new path with the 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) (SpecPath) Return a new path with the stem changed.</>
  • with_suffix(suffix) (SpecPath) Return a new path with the 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.</>
method

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

method

__str__()

Return the string representation of the path, suitable forpassing to system calls.

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

as_uri()

Return the path as a 'file' URI.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_absolute()

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

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

match(path_pattern, case_sensitive=None)

Return True if this path matches the given pattern.

method

stat(follow_symlinks=True)

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

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

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.

method

is_dir()

Whether this path is a directory.

method

is_file()

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

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

method

samefile(other_path)

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

method

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

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

method

read_bytes()

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

method

read_text(encoding=None, errors=None)

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

method

write_bytes(data)

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

method

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

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

generator

iterdir()

Yield path objects of the directory contents.

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

generator

glob(pattern, case_sensitive=None)

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

generator

rglob(pattern, case_sensitive=None)

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

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

absolute()

Return an absolute version of this path by prepending the currentworking directory. No normalization or symlink resolution is performed.

Use resolve() to get the canonical path to a file.

method

resolve(strict=False)

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

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

touch(mode=438, exist_ok=True)

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

method

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

Create a new directory at this given path.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

rmdir()

Remove this directory. The directory must be empty.

method

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.

method

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.

method

expanduser()

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

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_exists()

Asynchronously check if the path exists.

Returns (bool)

True if the path exists, False otherwise.

method

a_read_bytes()

Asynchronously read the file's bytes.

Returns (bytes)

File content as bytes.

method

a_read_text(encoding='utf-8')

Asynchronously read the file's text content.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
Returns (str)

File content as string.

method

a_write_bytes(data)

Asynchronously write bytes to the file.

Parameters
  • data (bytes) Bytes to write to the file.
Returns (Optional)

Number of bytes written. For some cloud paths, may return None.

method

a_write_text(data, encoding='utf-8')

Asynchronously write text to the file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
Returns (int)

Number of characters written.

method

a_iterdir()

Asynchronously iterate over directory contents.

Yields (AsyncGenerator)

PanPath instances for each item in the directory.

method

a_is_dir()

Asynchronously check if the path is a directory.

Returns (bool)

True if the path is a directory, False otherwise.

method

a_is_file()

Asynchronously check if the path is a file.

Returns (bool)

True if the path is a file, False otherwise.

method

a_stat(follow_symlinks=True)

Asynchronously get the file or directory's status information.

Returns (stat_result)

An object containing file status information (platform-dependent).

method

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

Asynchronously create a directory at this path.

Parameters
  • 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.
method

a_glob(pattern)

Asynchronously yield paths matching a glob pattern.

Parameters
  • pattern (str) Glob pattern to match.
Returns (AsyncGenerator)

List of PanPath instances matching the pattern.

method

a_rglob(pattern)

Asynchronously yield paths matching a recursive glob pattern.

Parameters
  • pattern (str) Recursive glob pattern to match.
Returns (AsyncGenerator)

List of PanPath instances matching the pattern.

method

a_walk()

Asynchronously walk the directory tree.

Yields (AsyncGenerator)

Tuples of (current_path, dirnames, filenames) at each level.

method

a_touch(mode=438, exist_ok=True)

Asynchronously create the file if it does not exist.

Parameters
  • 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.
method

a_rename(target)

Asynchronously rename this path to the target path.

Parameters
  • target (Union) New path to rename to.
Returns (PanPath)

The renamed PanPath instance.

method

a_replace(target)

Asynchronously replace this path with the target path.

Parameters
  • target (Union) New path to replace with.
Returns (PanPath)

The replaced PanPath instance.

method

a_rmdir()

Asynchronously remove the directory and its contents recursively.

method

a_rmtree(ignore_errors=False, onerror=None)

Asynchronously remove the directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, ignores errors during removal.
  • onerror (Any, optional) Optional function to call on errors.
method

a_copy(target)

Asynchronously copy this path to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
Returns (PanPath)

The copied PanPath instance.

method

a_copytree(target, follow_symlinks=True)

Asynchronously copy the directory and all its contents recursively to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
  • follow_symlinks (bool, optional) If True, copies the contents of symlinks.
Returns (PanPath)

The copied PanPath instance.

method

a_open(mode='r', encoding='utf-8', **kwargs)

Asynchronously open the file and return an async file handle.

Parameters
  • mode (str, optional) Mode to open the file (e.g., 'r', 'rb', 'w', 'wb').
  • encoding (str, optional) Text encoding to use (default: 'utf-8').
  • **kwargs (Any) Additional arguments to pass to the underlying open method.
Returns (AsyncFileHandle)

An async file handle.

method

walk()

Walk the directory tree.

Yields

Tuples of (current_path, dirnames, filenames) at each level.

staticmethod

__new__(cls, path, *args, mounted=None, **kwargs)

Factory method to create the appropriate SpecPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the spec path.
  • mounted (str | pathlib.path | none, optional) The path string or object representing the corresponding mountedpath. If None, the spec path itself will be used as the mounted path.
Returns (An instance of the appropriate SpecPath subclass based on the path type)

ss s s

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

method

__repr__()

Generate a string representation of the SpecPath.

Returns (str)

A string showing the class name, path, and mounted path (if different).

method

__eq__(other)

Check equality with another path object.

Two SpecPath objects are equal if they have the same path string and the same mounted path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the SpecPath.

Returns (int)

A hash value based on the path string and mounted path string.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (SpecPath)

A new spec path with the name changed in both the spec path and mounted path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (SpecPath)

A new spec path with the suffix changed in both the spec path and mounted path.

method

with_stem(stem)

Return a new path with the stem changed.

The stem is the filename without the suffix.

Parameters
  • stem The new stem for the path.
Returns (SpecPath)

A new spec path with the stem changed in both the spec path and mounted path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (SpecPath)

A new spec path with the segments appended to both the spec path and mounted path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (SpecPath)

A new spec path with the segment appended.

class

xqute.path.SpecLocalPath(path, *args, mounted=None, **kwargs) → xqute.path.speclocalpath | xqute.path.speccloudpath

Bases
xqute.path.SpecPath panpath.local_path.LocalPath pathlib.PosixPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a spec local path

This class represents a path in the local filesystem as it appears in the framework's environment, while maintaining a reference to its corresponding path in the remote execution environment.

Attributes
  • _mounted The corresponding path in the remote execution environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • mounted Get the corresponding mounted path in the remote environment.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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'] </>
Examples
>>> spec_path = SpecLocalPath("/local/data/file.txt",...                         mounted="/container/data/file.txt")
>>> str(spec_path)
'/local/data/file.txt'
>>> str(spec_path.mounted)
'/container/data/file.txt'
>>> spec_path.name
'file.txt'
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __hash__() (int) Generate a hash for the SpecPath.</>
  • __new__(cls, path, *args, mounted, **kwargs) (An instance of the appropriate SpecPath subclass based on the path type) Factory method to create the appropriate SpecPath subclass instance.</>
  • __repr__() (str) Generate a string representation of the SpecPath.</>
  • __str__() Return the string representation of the path, suitable forpassing to system calls. </>
  • __truediv__(key) (SpecPath) Implement the / operator for paths.</>
  • 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) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • 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) (SpecPath) Join path components to this path.</>
  • 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) (SpecPath) Return a new path with the 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) (SpecPath) Return a new path with the stem changed.</>
  • with_suffix(suffix) (SpecPath) Return a new path with the 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.</>
method

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

method

__str__()

Return the string representation of the path, suitable forpassing to system calls.

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

as_uri()

Return the path as a 'file' URI.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_absolute()

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

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

match(path_pattern, case_sensitive=None)

Return True if this path matches the given pattern.

method

stat(follow_symlinks=True)

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

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

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.

method

is_dir()

Whether this path is a directory.

method

is_file()

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

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

method

samefile(other_path)

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

method

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

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

method

read_bytes()

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

method

read_text(encoding=None, errors=None)

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

method

write_bytes(data)

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

method

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

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

generator

iterdir()

Yield path objects of the directory contents.

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

generator

glob(pattern, case_sensitive=None)

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

generator

rglob(pattern, case_sensitive=None)

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

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

absolute()

Return an absolute version of this path by prepending the currentworking directory. No normalization or symlink resolution is performed.

Use resolve() to get the canonical path to a file.

method

resolve(strict=False)

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

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

touch(mode=438, exist_ok=True)

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

method

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

Create a new directory at this given path.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

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.

method

expanduser()

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

method

a_touch(mode=438, exist_ok=True)

Create the file if it does not exist or update the modification time (async).

Parameters
  • 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.
method

a_rename(target)

Rename the file or directory to target.

Parameters
  • target (Union) New path
Returns (PanPath)

New path instance

method

a_replace(target)

Rename the file or directory to target, overwriting if target exists.

Parameters
  • target (Union) New path
Returns (PanPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Recursively copy the directory and all its contents to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
  • follow_symlinks (bool, optional) If True, copies the contents of symlinks.
Returns (PanPath)

The copied PanPath instance.

method

a_walk()

Asynchronously walk the directory tree.

Returns (AsyncGenerator)

A list of tuples (dirpath, dirnames, filenames)

method

a_glob(pattern)

Asynchronously yield paths matching the glob pattern.

Parameters
  • pattern (str) Glob pattern (relative)
Yields (AsyncGenerator)

Matching LocalPath instances

method

a_rglob(pattern)

Recursively yield all existing files matching the given pattern.

Parameters
  • pattern (str) Glob pattern (relative)
Yields (AsyncGenerator)

Matching LocalPath instances

method

a_exists() → bool

Check if path exists (async).

method

a_is_file() → bool

Check if path is a file (async).

method

a_is_dir() → bool

Check if path is a directory (async).

method

a_read_bytes() → bytes

Read file as bytes (async).

method

a_read_text(encoding='utf-8') → str

Read file as text (async).

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data) → int

Write bytes to file (async).

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file (async).

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

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

Create directory (async).

Parameters
  • 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.
method

a_rmdir()

Remove empty directory (async).

method

a_rmtree()

Recursively remove directory and its contents (async).

method

a_iterdir() → AsyncGenerator

List directory contents (async).

method

a_stat(follow_symlinks=True) → stat_result

Get file stats (async).

method

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

Open file and return async file handle.

Parameters
  • mode (str, optional) Mode to open the file (e.g., 'r', 'rb', 'w', 'wb').
  • encoding (Optional, optional) Text encoding to use (default: 'utf-8').
Returns (Any)

Async file handle from aiofiles

method

rename(target)

Rename the file or directory to target.

Parameters
  • target (Union) New path
Returns (PanPath)

New path instance

method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If True, follow symbolic links
Returns (PanPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Recursively copy the directory and all its contents to the target path.

Parameters
  • target (Union) Destination PanPath to copy to.
  • follow_symlinks (bool, optional) If True, copies the contents of symlinks.
Returns (PanPath)

The copied PanPath instance.

method

rmdir()

Remove empty directory.

method

rmtree()

Recursively remove directory and its contents.

generator

walk(*args, **kwargs)

Walk the directory tree.

Returns (Iterator)

A list of tuples (dirpath, dirnames, filenames)

staticmethod

__new__(cls, path, *args, mounted=None, **kwargs)

Factory method to create the appropriate SpecPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the spec path.
  • mounted (str | pathlib.path | none, optional) The path string or object representing the corresponding mountedpath. If None, the spec path itself will be used as the mounted path.
Returns (An instance of the appropriate SpecPath subclass based on the path type)

ss s s

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

method

__repr__()

Generate a string representation of the SpecPath.

Returns (str)

A string showing the class name, path, and mounted path (if different).

method

__eq__(other)

Check equality with another path object.

Two SpecPath objects are equal if they have the same path string and the same mounted path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the SpecPath.

Returns (int)

A hash value based on the path string and mounted path string.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (SpecPath)

A new spec path with the name changed in both the spec path and mounted path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (SpecPath)

A new spec path with the suffix changed in both the spec path and mounted path.

method

with_stem(stem)

Return a new path with the stem changed.

The stem is the filename without the suffix.

Parameters
  • stem The new stem for the path.
Returns (SpecPath)

A new spec path with the stem changed in both the spec path and mounted path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (SpecPath)

A new spec path with the segments appended to both the spec path and mounted path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (SpecPath)

A new spec path with the segment appended.

abstract class

xqute.path.SpecCloudPath(path, *args, mounted=None, **kwargs) → xqute.path.speclocalpath | xqute.path.speccloudpath

Bases
xqute.path.SpecPath panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a spec cloud path

This class represents a cloud storage path as it appears in the local environment where the framework runs, while maintaining a reference to its corresponding path in the remote execution environment.

Attributes
  • _mounted The corresponding path in the remote execution environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • mounted Get the corresponding mounted path in the remote environment.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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'] </>
Examples
>>> spec_path = SpecPath("gs://bucket/file.txt",...                    mounted="gs://container-bucket/file.txt")
>>> str(spec_path)
'gs://bucket/file.txt'
>>> str(spec_path.mounted)
'gs://container-bucket/file.txt'
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the SpecPath.</>
  • __new__(cls, path, *args, mounted, **kwargs) (An instance of the appropriate SpecPath subclass based on the path type) Factory method to create the appropriate SpecPath subclass instance.</>
  • __repr__() (str) Generate a string representation of the SpecPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (SpecPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (SpecPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (SpecPath) Return a new path with the 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) (SpecPath) Return a new path with the stem changed.</>
  • with_suffix(suffix) (SpecPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

method

a_write_bytes(data)

Write bytes to file.

method

a_write_text(data, encoding='utf-8') → int

Write text to file.

method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, *args, mounted=None, **kwargs)

Factory method to create the appropriate SpecPath subclass instance.

Parameters
  • path (str | pathlib.path) The path string or object representing the spec path.
  • *args (Any) Additional positional arguments passed to the path constructor.
  • mounted (str | pathlib.path | none, optional) The path string or object representing the corresponding mountedpath. If None, the spec path itself will be used as the mounted path.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
Returns (An instance of the appropriate SpecPath subclass based on the path type)

ss s s

method

__repr__()

Generate a string representation of the SpecPath.

Returns (str)

A string showing the class name, path, and mounted path (if different).

method

__eq__(other)

Check equality with another path object.

Two SpecPath objects are equal if they have the same path string and the same mounted path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the SpecPath.

Returns (int)

A hash value based on the path string and mounted path string.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (SpecPath)

A new spec path with the name changed in both the spec path and mounted path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (SpecPath)

A new spec path with the suffix changed in both the spec path and mounted path.

method

with_stem(stem)

Return a new path with the stem changed.

The stem is the filename without the suffix.

Parameters
  • stem The new stem for the path.
Returns (SpecPath)

A new spec path with the stem changed in both the spec path and mounted path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (SpecPath)

A new spec path with the segments appended to both the spec path and mounted path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (SpecPath)

A new spec path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

class

xqute.path.SpecGSPath(path, *args, mounted=None, **kwargs) → xqute.path.speclocalpath | xqute.path.speccloudpath

Bases
xqute.path.SpecCloudPath xqute.path.SpecPath panpath.gs_path.GSPath panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a spec Google Cloud Storage path

This class represents a Google Cloud Storage path as it appears in the local environment where the framework runs, while maintaining a reference to its corresponding path in the remote execution environment.

Attributes
  • _mounted The corresponding path in the remote execution environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • mounted Get the corresponding mounted path in the remote environment.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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'] </>
Examples
>>> spec_path = SpecPath("gs://bucket/file.txt",...                    mounted="gs://container-bucket/file.txt")
>>> isinstance(spec_path, SpecGSPath)
True
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the SpecPath.</>
  • __new__(cls, path, *args, mounted, **kwargs) (An instance of the appropriate SpecPath subclass based on the path type) Factory method to create the appropriate SpecPath subclass instance.</>
  • __repr__() (str) Generate a string representation of the SpecPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (SpecPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (SpecPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (SpecPath) Return a new path with the 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) (SpecPath) Return a new path with the stem changed.</>
  • with_suffix(suffix) (SpecPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data)

Write bytes to file.

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • mode (int, optional) File mode (permissions) to set if creating the file.
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, *args, mounted=None, **kwargs)

Factory method to create the appropriate SpecPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the spec path.
  • mounted (str | pathlib.path | none, optional) The path string or object representing the corresponding mountedpath. If None, the spec path itself will be used as the mounted path.
Returns (An instance of the appropriate SpecPath subclass based on the path type)

ss s s

method

__repr__()

Generate a string representation of the SpecPath.

Returns (str)

A string showing the class name, path, and mounted path (if different).

method

__eq__(other)

Check equality with another path object.

Two SpecPath objects are equal if they have the same path string and the same mounted path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the SpecPath.

Returns (int)

A hash value based on the path string and mounted path string.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (SpecPath)

A new spec path with the name changed in both the spec path and mounted path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (SpecPath)

A new spec path with the suffix changed in both the spec path and mounted path.

method

with_stem(stem)

Return a new path with the stem changed.

The stem is the filename without the suffix.

Parameters
  • stem The new stem for the path.
Returns (SpecPath)

A new spec path with the stem changed in both the spec path and mounted path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (SpecPath)

A new spec path with the segments appended to both the spec path and mounted path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (SpecPath)

A new spec path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

class

xqute.path.SpecAzurePath(path, *args, mounted=None, **kwargs) → xqute.path.speclocalpath | xqute.path.speccloudpath

Bases
xqute.path.SpecCloudPath xqute.path.SpecPath panpath.azure_path.AzurePath panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a spec Azure Blob Storage path

This class represents an Azure Blob Storage path as it appears in the local environment where the framework runs, while maintaining a reference to its corresponding path in the remote execution environment.

Attributes
  • _mounted The corresponding path in the remote execution environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • mounted Get the corresponding mounted path in the remote environment.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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'] </>
Examples
>>> spec_path = SpecPath("az://container/blob",...                    mounted="az://remote-container/blob")
>>> isinstance(spec_path, SpecAzurePath)
True
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the SpecPath.</>
  • __new__(cls, path, *args, mounted, **kwargs) (An instance of the appropriate SpecPath subclass based on the path type) Factory method to create the appropriate SpecPath subclass instance.</>
  • __repr__() (str) Generate a string representation of the SpecPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (SpecPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (SpecPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (SpecPath) Return a new path with the 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) (SpecPath) Return a new path with the stem changed.</>
  • with_suffix(suffix) (SpecPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data)

Write bytes to file.

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • mode (int, optional) File mode (permissions) to set if creating the file.
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, *args, mounted=None, **kwargs)

Factory method to create the appropriate SpecPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the spec path.
  • mounted (str | pathlib.path | none, optional) The path string or object representing the corresponding mountedpath. If None, the spec path itself will be used as the mounted path.
Returns (An instance of the appropriate SpecPath subclass based on the path type)

ss s s

method

__repr__()

Generate a string representation of the SpecPath.

Returns (str)

A string showing the class name, path, and mounted path (if different).

method

__eq__(other)

Check equality with another path object.

Two SpecPath objects are equal if they have the same path string and the same mounted path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the SpecPath.

Returns (int)

A hash value based on the path string and mounted path string.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (SpecPath)

A new spec path with the name changed in both the spec path and mounted path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (SpecPath)

A new spec path with the suffix changed in both the spec path and mounted path.

method

with_stem(stem)

Return a new path with the stem changed.

The stem is the filename without the suffix.

Parameters
  • stem The new stem for the path.
Returns (SpecPath)

A new spec path with the stem changed in both the spec path and mounted path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (SpecPath)

A new spec path with the segments appended to both the spec path and mounted path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (SpecPath)

A new spec path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.

class

xqute.path.SpecS3Path(path, *args, mounted=None, **kwargs) → xqute.path.speclocalpath | xqute.path.speccloudpath

Bases
xqute.path.SpecCloudPath xqute.path.SpecPath panpath.s3_path.S3Path panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

A class to represent a spec Amazon S3 path

This class represents an Amazon S3 path as it appears in the local environment where the framework runs, while maintaining a reference to its corresponding path in the remote execution environment.

Attributes
  • _mounted The corresponding path in the remote execution environment.
  • anchor The concatenation of the drive and root, or ''.</>
  • async_client (AsyncClient) Get or create the async client for this path.</>
  • client (SyncClient) Get or create the sync client for this path.</>
  • cloud_prefix (str) Return the cloud prefix (e.g., 's3://bucket').</>
  • drive The drive prefix (letter or UNC path), if any.</>
  • key (str) Return the key/blob name without the cloud prefix.</>
  • mounted Get the corresponding mounted path in the remote environment.</>
  • name The final path component, if any.</>
  • parent Get the parent directory of this 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'] </>
Examples
>>> spec_path = SpecPath("s3://bucket/key",...                    mounted="s3://remote-bucket/key")
>>> isinstance(spec_path, SpecS3Path)
True
Methods
  • __bytes__() Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>
  • __eq__(other) (bool) Check equality with another path object.</>
  • __fspath__() (str) Return the filesystem path representation.</>
  • __hash__() (int) Generate a hash for the SpecPath.</>
  • __new__(cls, path, *args, mounted, **kwargs) (An instance of the appropriate SpecPath subclass based on the path type) Factory method to create the appropriate SpecPath subclass instance.</>
  • __repr__() (str) Generate a string representation of the SpecPath.</>
  • __rtruediv__(other) (CloudPath) Right join paths while preserving type and client.</>
  • __str__() (str) Return properly formatted cloud URI with double slash.</>
  • __truediv__(key) (SpecPath) Implement the / operator for paths.</>
  • a_copy(target, follow_symlinks) (PanPath) Copy file to target.</>
  • a_copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • a_exists() (bool) Check if path exists.</>
  • a_glob(pattern) (AsyncGenerator) Glob for files matching pattern.</>
  • a_is_dir() (bool) Check if path is a directory.</>
  • a_is_file() (bool) Check if path is a file.</>
  • a_is_symlink() (bool) Check if this is a symbolic link (via metadata).</>
  • a_iterdir() (AsyncGenerator) List directory contents (async version returns list).</>
  • a_mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • a_open(mode, encoding, **kwargs) (AsyncFileHandle) Open file and return async file handle.</>
  • a_read_bytes() (bytes) Read file as bytes.</>
  • a_read_text(encoding) (str) Read file as text.</>
  • a_readlink() (CloudPath) Read symlink target from metadata.</>
  • a_rename(target) (CloudPath) Rename/move file to target.</>
  • a_replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • a_resolve() (PanPath) Resolve to absolute path (no-op for cloud paths).</>
  • a_rglob(pattern) (AsyncGenerator) Recursively glob for files matching pattern.</>
  • a_rmdir() Remove empty directory marker.</>
  • a_rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • a_stat(follow_symlinks) (Any) Get file stats.</>
  • a_symlink_to(target, target_is_directory) Create symlink pointing to target (via metadata).</>
  • a_touch(mode, exist_ok) Create empty file.</>
  • a_unlink(missing_ok) Delete file.</>
  • a_walk() (AsyncGenerator) Walk directory tree (like os.walk).</>
  • a_write_bytes(data) Write bytes to file.</>
  • a_write_text(data, encoding) (int) Write text to file.</>
  • absolute() (CloudPath) Return absolute path - cloud paths are already absolute.</>
  • as_posix() Return the string representation of the path with forward (/)slashes. </>
  • as_uri() (str) Return the path as a URI (same as string representation).</>
  • chmod(mode, follow_symlinks) Change the permissions of the path, like os.chmod().</>
  • copy(target, follow_symlinks) (CloudPath) Copy file to target.</>
  • copytree(target, follow_symlinks) (CloudPath) Copy directory tree to target recursively.</>
  • cwd() Return a new path pointing to the current working directory.</>
  • exists() (bool) Check if path exists.</>
  • expanduser() Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser) </>
  • get_fspath() (PanPath) Get the corresponding local filesystem path and copy from cloud.</>
  • glob(pattern) (Iterator) Glob for files matching 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() (bool) Cloud paths are always absolute.</>
  • is_block_device() Whether this path is a block device.</>
  • is_char_device() Whether this path is a character device.</>
  • is_dir() (bool) Check if path is a directory.</>
  • is_fifo() Whether this path is a FIFO.</>
  • is_file() (bool) Check if path is a file.</>
  • 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() (bool) Check if this is a symbolic link (via metadata).</>
  • iterdir() (CloudPath) Iterate over directory contents.</>
  • joinpath(*pathsegments) (SpecPath) Join path components to this path.</>
  • 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(pattern) (bool) Match path against glob pattern.</>
  • mkdir(mode, parents, exist_ok) Create a directory marker in cloud storage.</>
  • open(mode, encoding, **kwargs) (Union) Open file for reading/writing.</>
  • owner() Return the login name of the file owner.</>
  • read_bytes() (bytes) Read file as bytes.</>
  • read_text(encoding) (str) Read file as text.</>
  • readlink() (CloudPath) Read symlink target from metadata.</>
  • 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) (CloudPath) Rename/move file to target.</>
  • replace(target) (CloudPath) Replace file at target (overwriting if exists).</>
  • resolve() (CloudPath) Resolve to absolute path (no-op for cloud paths).</>
  • rglob(pattern) (Iterator) Recursively glob for files matching pattern.</>
  • rmdir() Remove empty directory marker.</>
  • rmtree(ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • samefile(other) (bool) Check if this path refers to same file as other.</>
  • stat(follow_symlinks) (Any) Get file stats.</>
  • symlink_to(target) Create symlink pointing to target (via metadata).</>
  • touch(exist_ok) Create empty file.</>
  • unlink(missing_ok) Delete file.</>
  • walk() (Iterator) Walk directory tree (like os.walk).</>
  • with_name(name) (SpecPath) Return a new path with the 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) (SpecPath) Return a new path with the stem changed.</>
  • with_suffix(suffix) (SpecPath) Return a new path with the suffix changed.</>
  • write_bytes(data) Write bytes to file.</>
  • write_text(data, encoding) Write text to file.</>
method

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

method

as_posix()

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

method

__bytes__()

Return the bytes representation of the path. This is onlyrecommended to use under Unix.

method

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.

method

is_relative_to(other, *_deprecated)

Return True if the path is relative to another path or False.

method

is_reserved()

Return True if the path contains one of the special names reservedby the system, if any.

method

lstat()

Like stat(), except if the path points to a symlink, the symlink'sstatus information is returned, rather than its target's.

method

is_mount()

Check if this path is a mount point

method

is_junction()

Whether this path is a junction.

method

is_block_device()

Whether this path is a block device.

method

is_char_device()

Whether this path is a character device.

method

is_fifo()

Whether this path is a FIFO.

method

is_socket()

Whether this path is a socket.

classmethod

cwd()

Return a new path pointing to the current working directory.

classmethod

home()

Return a new path pointing to the user's home directory (asreturned by os.path.expanduser('~')).

method

owner()

Return the login name of the file owner.

method

group()

Return the group name of the file gid.

method

chmod(mode, follow_symlinks=True)

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

method

lchmod(mode)

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

method

expanduser()

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

method

__rtruediv__(other) → CloudPath

Right join paths while preserving type and client.

method

__str__() → str

Return properly formatted cloud URI with double slash.

method

exists() → bool

Check if path exists.

method

read_bytes() → bytes

Read file as bytes.

method

read_text(encoding='utf-8') → str

Read file as text.

method

write_bytes(data)

Write bytes to file.

method

write_text(data, encoding='utf-8')

Write text to file.

generator

iterdir() → CloudPath

Iterate over directory contents.

method

is_dir() → bool

Check if path is a directory.

method

is_file() → bool

Check if path is a file.

method

stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

open(mode='r', encoding=None, **kwargs) → Union

Open file for reading/writing.

method

absolute() → CloudPath

Return absolute path - cloud paths are already absolute.

method

is_absolute() → bool

Cloud paths are always absolute.

method

as_uri() → str

Return the path as a URI (same as string representation).

method

match(pattern) → bool

Match path against glob pattern.

Override to work correctly with cloud URIs by matching against the key portion of the path (excluding scheme and bucket).

generator

glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (Iterator)

List of matching paths

generator

rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (Iterator)

List of matching paths (recursive)

generator

walk()

Walk directory tree (like os.walk).

Returns (Iterator)

List of (dirpath, dirnames, filenames) tuples

method

touch(exist_ok=True)

Create empty file.

Parameters
  • exist_ok (bool, optional) If False, raise error if file exists
method

rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

rmdir()

Remove empty directory marker.

method

resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (CloudPath)

Self (cloud paths are already absolute)

method

samefile(other)

Check if this path refers to same file as other.

Parameters
  • other (Union) Path to compare
Returns (bool)

True if paths are the same

method

rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (CloudPath)

Target path instance

method

copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_exists() → bool

Check if path exists.

method

a_read_bytes() → bytes

Read file as bytes.

method

a_read_text(encoding='utf-8') → str

Read file as text.

Parameters
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_write_bytes(data)

Write bytes to file.

Parameters
  • data (bytes) Bytes to write to the file.
method

a_write_text(data, encoding='utf-8') → int

Write text to file.

Parameters
  • data (str) Text to write to the file.
  • encoding (str, optional) Text encoding to use (default: 'utf-8')
method

a_iterdir() → AsyncGenerator

List directory contents (async version returns list).

method

a_is_dir() → bool

Check if path is a directory.

method

a_is_file() → bool

Check if path is a file.

method

a_stat(follow_symlinks=True) → Any

Get file stats.

method

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

Create a directory marker in cloud storage.

In cloud storage (S3, GCS, Azure), directories are implicit. This method creates an empty object with a trailing slash to serve as a directory marker.

Parameters
  • mode (int, optional) Ignored (for compatibility with pathlib)
  • parents (bool, optional) If True, create parent directories as needed
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

a_glob(pattern)

Glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", "/.py")
Returns (AsyncGenerator)

List of matching paths

method

a_rglob(pattern)

Recursively glob for files matching pattern.

Parameters
  • pattern (str) Pattern to match (e.g., ".txt", ".py")
Returns (AsyncGenerator)

List of matching paths (recursive)

method

a_walk()

Walk directory tree (like os.walk).

Returns (AsyncGenerator)

List of (dirpath, dirnames, filenames) tuples

method

a_touch(mode=438, exist_ok=True)

Create empty file.

Parameters
  • mode (int, optional) File mode (permissions) to set if creating the file.
  • exist_ok (bool, optional) If False, raise error if file exists
method

a_rename(target)

Rename/move file to target.

Can move between cloud and local paths.

Parameters
  • target (Union) New path (can be cloud or local)
Returns (CloudPath)

New path instance

method

a_replace(target)

Replace file at target (overwriting if exists).

Parameters
  • target (Union) Target path
Returns (CloudPath)

New path instance

method

a_resolve()

Resolve to absolute path (no-op for cloud paths).

Returns (PanPath)

Self (cloud paths are already absolute)

method

a_rmdir()

Remove empty directory marker.

method

a_rmtree(ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

Parameters
  • ignore_errors (bool, optional) If True, errors are ignored
  • onerror (Optional, optional) Callable that accepts (function, path, excinfo)
method

a_copy(target, follow_symlinks=True)

Copy file to target.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
Returns (PanPath)

Target path instance

method

a_copytree(target, follow_symlinks=True)

Copy directory tree to target recursively.

Can copy between cloud and local paths.

Parameters
  • target (Union) Destination path (can be cloud or local)
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
Returns (CloudPath)

Target path instance

method

a_open(mode='r', encoding=None, **kwargs)

Open file and return async file handle.

Parameters
  • mode (str, optional) File mode (e.g., 'r', 'w', 'rb', 'wb')
  • encoding (Optional, optional) Text encoding (for text modes)
  • **kwargs (Any) Additional arguments passed to the async client
Returns (AsyncFileHandle)

Async file handle from the async client

staticmethod

__new__(cls, path, *args, mounted=None, **kwargs)

Factory method to create the appropriate SpecPath subclass instance.

Parameters
  • *args (Any) Additional positional arguments passed to the path constructor.
  • **kwargs (Any) Additional keyword arguments passed to the path constructor.
  • path (str | pathlib.path) The path string or object representing the spec path.
  • mounted (str | pathlib.path | none, optional) The path string or object representing the corresponding mountedpath. If None, the spec path itself will be used as the mounted path.
Returns (An instance of the appropriate SpecPath subclass based on the path type)

ss s s

method

__repr__()

Generate a string representation of the SpecPath.

Returns (str)

A string showing the class name, path, and mounted path (if different).

method

__eq__(other)

Check equality with another path object.

Two SpecPath objects are equal if they have the same path string and the same mounted path string.

Parameters
  • other (Any) Another object to compare with.
Returns (bool)

True if the paths are equal, False otherwise.

method

__hash__()

Generate a hash for the SpecPath.

Returns (int)

A hash value based on the path string and mounted path string.

method

with_name(name)

Return a new path with the name changed.

Parameters
  • name The new name for the path.
Returns (SpecPath)

A new spec path with the name changed in both the spec path and mounted path.

method

with_suffix(suffix)

Return a new path with the suffix changed.

Parameters
  • suffix The new suffix for the path.
Returns (SpecPath)

A new spec path with the suffix changed in both the spec path and mounted path.

method

with_stem(stem)

Return a new path with the stem changed.

The stem is the filename without the suffix.

Parameters
  • stem The new stem for the path.
Returns (SpecPath)

A new spec path with the stem changed in both the spec path and mounted path.

method

joinpath(*pathsegments)

Join path components to this path.

Parameters
  • *pathsegments The path segments to append to this path.
Returns (SpecPath)

A new spec path with the segments appended to both the spec path and mounted path.

method

__truediv__(key)

Implement the / operator for paths.

Parameters
  • key The path segment to append to this path.
Returns (SpecPath)

A new spec path with the segment appended.

method

__fspath__()

Return the filesystem path representation.

Returns (str)

The filesystem path as a string.

method

get_fspath()

Get the corresponding local filesystem path and copy from cloud.

Returns (PanPath)

The path as it appears in the local filesystem.