panpath.gs_path
Google Cloud Storage path implementation (sync and async methods).
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(CloudPath) — Return parent directory as same path type.</>parents— A sequence of this path's logical parents.</>parts— An object providing sequence-like access to thecomponents in the filesystem path. </>root— The root of the path, if any.</>stem— The final path component, minus its last suffix.</>suffix— The final component's last suffix, if any.
This includes the leading period. For example: '.txt' </>suffixes— A list of the final component's suffixes, if any.
These include the leading periods. For example: ['.tar', '.gz'] </>
__bytes__()— Return the bytes representation of the path. This is onlyrecommended to use under Unix. </>__eq__(other)(bool) — Check equality.</>__hash__()(int) — Return hash of path.</>__new__(cls,*args,**kwargs)(CloudPath) — Create new cloud path instance.</>__rtruediv__(other)(CloudPath) — Right join paths while preserving type and client.</>__str__()(str) — Return properly formatted cloud URI with double slash.</>__truediv__(other)(CloudPath) — Join paths while preserving type and client.</>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) </>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(*args)(CloudPath) — Join paths while preserving type and client.</>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)— Return a new path with the file name changed.</>with_segments(*pathsegments)— Construct a new path object from any number of path-like objects.Subclasses may override this method to customize how new path objects are created from methods likeiterdir(). </>with_stem(stem)— Return a new path with the stem changed.</>with_suffix(suffix)— Return a new path with the file suffix changed. If the pathhas no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path. </>write_bytes(data)— Write bytes to file.</>write_text(data,encoding)— Write text to file.</>
with_segments(*pathsegments)
Construct a new path object from any number of path-like objects.Subclasses may override this method to customize how new path objects
are created from methods like iterdir().
with_suffix(suffix)
Return a new path with the file suffix changed. If the pathhas no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.
relative_to(other, *_deprecated, walk_up=False)
Return the relative path to another path identified by the passedarguments. If the operation is not possible (because this is not related to the other path), raise ValueError.
The walk_up parameter controls whether .. may be used to resolve
the path.
is_relative_to(other, *_deprecated)
Return True if the path is relative to another path or False.
is_reserved()
Return True if the path contains one of the special names reservedby the system, if any.
is_junction()
Whether this path is a junction.
is_block_device()
Whether this path is a block device.
is_char_device()
Whether this path is a character device.
hardlink_to(target)
Make this path a hard link pointing to the same file as target.
Note the order of arguments (self, target) is the reverse of os.link's.
expanduser()
Return a new path with expanded ~ and ~user constructs(as returned by os.path.expanduser)
__str__() → str
Return properly formatted cloud URI with double slash.
exists() → bool
Check if path exists.
read_bytes() → bytes
Read file as bytes.
read_text(encoding='utf-8') → str
Read file as text.
write_bytes(data)
Write bytes to file.
write_text(data, encoding='utf-8')
Write text to file.
unlink(missing_ok=False)
Delete file.
is_dir() → bool
Check if path is a directory.
is_file() → bool
Check if path is a file.
stat(follow_symlinks=True) → Any
Get file stats.
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.
mode(int, optional) — Ignored (for compatibility with pathlib)parents(bool, optional) — If True, create parent directories as neededexist_ok(bool, optional) — If True, don't raise error if directory already exists
open(mode='r', encoding=None, **kwargs) → Union
Open file for reading/writing.
__eq__(other) → bool
Check equality.
__hash__() → int
Return hash of path.
is_absolute() → bool
Cloud paths are always absolute.
as_uri() → str
Return the path as a URI (same as string representation).
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).
glob(pattern)
Glob for files matching pattern.
pattern(str) — Pattern to match (e.g., ".txt", "**/.py")
List of matching paths
rglob(pattern)
Recursively glob for files matching pattern.
pattern(str) — Pattern to match (e.g., ".txt", ".py")
List of matching paths (recursive)
walk()
Walk directory tree (like os.walk).
List of (dirpath, dirnames, filenames) tuples
touch(exist_ok=True)
Create empty file.
exist_ok(bool, optional) — If False, raise error if file exists
rmdir()
Remove empty directory marker.
samefile(other)
Check if this path refers to same file as other.
other(Union) — Path to compare
True if paths are the same
is_symlink()
Check if this is a symbolic link (via metadata).
True if symlink metadata exists
symlink_to(target)
Create symlink pointing to target (via metadata).
target(Union) — Path this symlink should point to (absolute with scheme or relative)
rmtree(ignore_errors=False, onerror=None)
Remove directory and all its contents recursively.
ignore_errors(bool, optional) — If True, errors are ignoredonerror(Optional, optional) — Callable that accepts (function, path, excinfo)
copytree(target, follow_symlinks=True)
Copy directory tree to target recursively.
Can copy between cloud and local paths.
target(Union) — Destination path (can be cloud or local)follow_symlinks(bool, optional) — If False, symlinks are copied as symlinks (not dereferenced)
Target path instance
a_exists() → bool
Check if path exists.
a_read_bytes() → bytes
Read file as bytes.
a_read_text(encoding='utf-8') → str
Read file as text.
encoding(str, optional) — Text encoding to use (default: 'utf-8')
a_write_bytes(data)
Write bytes to file.
data(bytes) — Bytes to write to the file.
a_write_text(data, encoding='utf-8') → int
Write text to file.
data(str) — Text to write to the file.encoding(str, optional) — Text encoding to use (default: 'utf-8')
a_unlink(missing_ok=False)
Delete file.
missing_ok(bool, optional) — If True, does not raise an error if the file does not exist.
a_iterdir() → AsyncGenerator
List directory contents (async version returns list).
a_is_dir() → bool
Check if path is a directory.
a_is_file() → bool
Check if path is a file.
a_stat(follow_symlinks=True) → Any
Get file stats.
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.
mode(int, optional) — Ignored (for compatibility with pathlib)parents(bool, optional) — If True, create parent directories as neededexist_ok(bool, optional) — If True, don't raise error if directory already exists
a_glob(pattern)
Glob for files matching pattern.
pattern(str) — Pattern to match (e.g., ".txt", "**/.py")
List of matching paths
a_rglob(pattern)
Recursively glob for files matching pattern.
pattern(str) — Pattern to match (e.g., ".txt", ".py")
List of matching paths (recursive)
a_walk()
Walk directory tree (like os.walk).
List of (dirpath, dirnames, filenames) tuples
a_touch(mode=438, exist_ok=True)
Create empty file.
mode(int, optional) — File mode (permissions) to set if creating the file.exist_ok(bool, optional) — If False, raise error if file exists
a_rmdir()
Remove empty directory marker.
a_is_symlink()
Check if this is a symbolic link (via metadata).
True if symlink metadata exists
a_symlink_to(target, target_is_directory=False)
Create symlink pointing to target (via metadata).
target(Union) — Path this symlink should point to (absolute with scheme or relative)target_is_directory(bool, optional) — Ignored (for compatibility with pathlib)
a_rmtree(ignore_errors=False, onerror=None)
Remove directory and all its contents recursively.
ignore_errors(bool, optional) — If True, errors are ignoredonerror(Optional, optional) — Callable that accepts (function, path, excinfo)
a_copytree(target, follow_symlinks=True)
Copy directory tree to target recursively.
Can copy between cloud and local paths.
target(Union) — Destination path (can be cloud or local)follow_symlinks(bool, optional) — If False, symlinks are copied as symlinks (not dereferenced)
Target path instance
a_open(mode='r', encoding=None, **kwargs)
Open file and return async file handle.
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
Async file handle from the async client