Skip to content
module

panpath.azure_async_client

Async Azure Blob Storage client implementation.

Classes
class

panpath.azure_async_client.AsyncAzureBlobClient(connection_string=None, **kwargs)

Asynchronous Azure Blob Storage client implementation.

Methods
  • __aenter__() (AsyncClient) Enter async context manager.</>
  • __aexit__(exc_type, exc_val, exc_tb) Exit async context manager.</>
  • close() Close the client and cleanup resources.</>
  • copy(source, target, follow_symlinks) Copy file to target.</>
  • copytree(source, target, follow_symlinks) Copy directory tree to target recursively.</>
  • delete(path) Delete Azure blob.</>
  • exists(path) (bool) Check if Azure blob exists.</>
  • get_metadata(path) (dict) Get blob metadata.</>
  • glob(path, pattern) Glob for files matching pattern.</>
  • is_dir(path) (bool) Check if Azure path is a directory.</>
  • is_file(path) (bool) Check if Azure path is a file.</>
  • is_symlink(path) (bool) Check if path is a symlink (has symlink metadata).</>
  • list_dir(path) (list) List Azure blobs with prefix.</>
  • mkdir(path, parents, exist_ok) Create a directory marker (empty blob with trailing slash).</>
  • open(path, mode, encoding, **kwargs) (Any) Open Azure blob for reading/writing.</>
  • read_bytes(path) (bytes) Read Azure blob as bytes.</>
  • read_text(path, encoding) (str) Read Azure blob as text.</>
  • readlink(path) (str) Read symlink target from metadata.</>
  • rename(source, target) Rename/move file.</>
  • rmdir(path) Remove directory marker.</>
  • rmtree(path, ignore_errors, onerror) Remove directory and all its contents recursively.</>
  • set_metadata(path, metadata) Set blob metadata.</>
  • stat(path) (stat_result) Get Azure blob metadata.</>
  • symlink_to(path, target) Create symlink by storing target in metadata.</>
  • touch(path, mode, exist_ok) Create empty file.</>
  • walk(path) Walk directory tree.</>
  • write_bytes(path, data) Write bytes to Azure blob.</>
  • write_text(path, data, encoding) (int) Write text to Azure blob.</>
method

__aenter__()AsyncClient

Enter async context manager.

method

__aexit__(exc_type, exc_val, exc_tb)

Exit async context manager.

method

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

Read Azure blob as text.

method

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

Write text to Azure blob.

method

close()

Close the client and cleanup resources.

method

exists(path) → bool

Check if Azure blob exists.

method

read_bytes(path) → bytes

Read Azure blob as bytes.

method

write_bytes(path, data)

Write bytes to Azure blob.

method

delete(path)

Delete Azure blob.

method

list_dir(path) → list

List Azure blobs with prefix.

method

is_dir(path) → bool

Check if Azure path is a directory.

method

is_file(path) → bool

Check if Azure path is a file.

method

stat(path) → stat_result

Get Azure blob metadata.

method

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

Open Azure blob for reading/writing.

Note: For better streaming support, use a_open() instead. This method returns a file-like object that supports the standard file API.

Parameters
  • path (str) Azure path
  • mode (str, optional) File mode
  • encoding (Optional, optional) Text encoding
  • **kwargs (Any) Additional arguments (chunk_size, upload_warning_threshold,upload_interval supported)
method

mkdir(path, parents=False, exist_ok=False)

Create a directory marker (empty blob with trailing slash).

Parameters
  • path (str) Azure path (az://container/path or azure://container/path)
  • parents (bool, optional) If True, create parent directories as needed (ignored for Azure)
  • exist_ok (bool, optional) If True, don't raise error if directory already exists
method

get_metadata(path)

Get blob metadata.

Parameters
  • path (str) Azure path
Returns (dict)

Dictionary of metadata key-value pairs

method

set_metadata(path, metadata)

Set blob metadata.

Parameters
  • path (str) Azure path
  • metadata (dict) Dictionary of metadata key-value pairs
method

glob(path, pattern)

Glob for files matching pattern.

Parameters
  • path (str) Base Azure path
  • pattern (str) Glob pattern (e.g., ".txt", "**/.py")
Yields

Matching paths as strings or PanPath objects

method

walk(path)

Walk directory tree.

Parameters
  • path (str) Base Azure path
Yields

Tuples of (dirpath, dirnames, filenames)

method

touch(path, mode=None, exist_ok=True)

Create empty file.

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

rename(source, target)

Rename/move file.

Parameters
  • source (str) Source Azure path
  • target (str) Target Azure path
method

rmdir(path)

Remove directory marker.

Parameters
  • path (str) Azure path
method

rmtree(path, ignore_errors=False, onerror=None)

Remove directory and all its contents recursively.

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

copy(source, target, follow_symlinks=True)

Copy file to target.

Parameters
  • source (str) Source Azure path
  • target (str) Target Azure path
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
method

copytree(source, target, follow_symlinks=True)

Copy directory tree to target recursively.

Parameters
  • source (str) Source Azure path
  • target (str) Target Azure path
  • follow_symlinks (bool, optional) If False, symlinks are copied as symlinks (not dereferenced)
class

panpath.azure_async_client.AzureAsyncFileHandle(*args, **kwargs)

Async file handle for Azure with chunked streaming support.

Uses Azure SDK's download_blob streaming API.

Attributes
  • closed (bool) Check if file is closed.</>
Methods
  • __aenter__() (AsyncFileHandle) Enter async context manager.</>
  • __aexit__(exc_type, exc_val, exc_tb) Exit async context manager.</>
  • __aiter__() (AsyncFileHandle) Support async iteration over lines.</>
  • __anext__() (Union) Get next line in async iteration.</>
  • close() Close the file and flush write buffer to cloud storage.</>
  • flush() Flush write buffer to cloud storage.</>
  • read(size) (Union) Read and return up to size bytes/characters.</>
  • readline(size) (Union) Read and return one line from the file.</>
  • readlines() (List) Read and return all lines from the file.</>
  • reset_stream() Reset the underlying stream to the beginning.</>
  • seek(offset, whence) (int) Change stream position (forward seeking only).</>
  • tell() (int) Return current stream position.</>
  • write(data) (int) Write data to the file.</>
  • writelines(lines) Write a list of lines to the file.</>
method

flush()

Flush write buffer to cloud storage.

After open, all flushes append to existing content using provider-native append operations. The difference between 'w' and 'a' modes is that 'w' clears existing content on open, while 'a' preserves it.

method

__aenter__()AsyncFileHandle

Enter async context manager.

method

__aexit__(exc_type, exc_val, exc_tb)

Exit async context manager.

method

read(size=-1)

Read and return up to size bytes/characters.

Parameters
  • size (int, optional) Number of bytes/chars to read (-1 for all)
Returns (Union)

Data read from file

method

readline(size=-1) → Union

Read and return one line from the file.

method

readlines() → List

Read and return all lines from the file.

method

write(data) → int

Write data to the file.

method

writelines(lines)

Write a list of lines to the file.

method

close()

Close the file and flush write buffer to cloud storage.

method

__aiter__()AsyncFileHandle

Support async iteration over lines.

method

__anext__() → Union

Get next line in async iteration.

method

tell()

Return current stream position.

Returns (int)

Current position in the file

method

seek(offset, whence=0)

Change stream position (forward seeking only).

Parameters
  • offset (int) Position offset
  • whence (int, optional) Reference point (0=start, 1=current, 2=end)
Returns (int)

New absolute position

Raises
  • OSError If backward seeking is attempted
  • ValueError If called in write mode or on closed file

Note

  • Only forward seeking is supported due to streaming limitations
  • SEEK_END (whence=2) is not supported as blob size may be unknown
  • Backward seeking requires re-opening the stream
method

reset_stream()

Reset the underlying stream to the beginning.