Skip to content
module

panpath.azure_path

Azure Blob Storage path implementation.

Classes
class

panpath.azure_path.AzurePath(*args, **kwargs)CloudPath

Bases
panpath.cloud.CloudPath panpath.base.PanPath pathlib.Path pathlib.PurePosixPath pathlib.PurePath

Azure Blob Storage path implementation (sync and async methods).

Attributes
  • 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'] </>
Methods
  • __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 like iterdir(). </>
  • with_stem(stem) Return a new path with the stem changed.</>
  • with_suffix(suffix) Return a new path with the file suffix changed. If the 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.</>
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_name(name)

Return a new path with the file name changed.

method

with_stem(stem)

Return a new path with the stem changed.

method

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.

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)

staticmethod

__new__(cls, *args, **kwargs)CloudPath

Create new cloud path instance.

method

__truediv__(other)CloudPath

Join paths while preserving type and client.

method

__rtruediv__(other)CloudPath

Right join paths while preserving type and client.

method

joinpath(*args)CloudPath

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

__eq__(other) → bool

Check equality.

method

__hash__() → int

Return hash of path.

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