panpath.clients
Base client classes for sync and async cloud storage operations.
Client()— Base class for cloud storage clients.</>SyncClient()— Base class for synchronous cloud storage clients.</>AsyncClient()— Base class for asynchronous cloud storage clients.</>AsyncFileHandle(client_factory,bucket,blob,prefix,mode,encoding,chunk_size,upload_warning_threshold,upload_interval)— Base class for async file handles.</>SyncFileHandle(client,bucket,blob,prefix,mode,encoding,chunk_size,upload_warning_threshold,upload_interval)— Base class for sync file handles.</>
panpath.clients.Client()
Base class for cloud storage clients.
open(path, mode='r', encoding=None, **kwargs)
Open file and return sync/async file handle.
path(str) — Cloud storage pathmode(str, optional) — File mode ('r', 'w', 'rb', 'wb', 'a', 'ab')encoding(Optional, optional) — Text encoding (for text modes)**kwargs(Any) — Additional arguments for specific implementations
SyncFileHandle/AsyncFileHandle instance
panpath.clients.SyncClient()
Base class for synchronous cloud storage clients.
copy(src,dst,follow_symlinks)— Copy file from src to dst.</>copytree(src,dst,follow_symlinks)— Copy directory tree from src to dst recursively.</>delete(path)— Delete file.</>exists(path)(bool) — Check if path exists.</>get_metadata(path)(dict) — Get object metadata.</>glob(path,pattern)(Iterator) — Find all paths matching pattern.</>is_dir(path)(bool) — Check if path is a directory.</>is_file(path)(bool) — Check if path is a file.</>is_symlink(path)(bool) — Check if path is a symlink (has symlink metadata).</>list_dir(path)(Iterator) — List directory contents.</>mkdir(path,parents,exist_ok)— Create a directory marker (empty blob with trailing slash).</>open(path,mode,encoding,**kwargs)(Union) — Open file and return sync/async file handle.</>read_bytes(path)(bytes) — Read file as bytes.</>read_text(path,encoding)(str) — Read file as text.</>readlink(path)(str) — Read symlink target from metadata.</>rename(src,dst)— 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 object metadata.</>stat(path)(Any) — Get file stats.</>symlink_to(path,target)— Create symlink by storing target in metadata.</>touch(path,exist_ok)— Create empty file or update metadata.</>walk(path)(Iterator) — Walk directory tree.</>write_bytes(path,data)— Write bytes to file.</>write_text(path,data,encoding)— Write text to file.</>
open(path, mode='r', encoding=None, **kwargs)
Open file and return sync/async file handle.
path(str) — Cloud storage pathmode(str, optional) — File mode ('r', 'w', 'rb', 'wb', 'a', 'ab')encoding(Optional, optional) — Text encoding (for text modes)**kwargs(Any) — Additional arguments for specific implementations
SyncFileHandle/AsyncFileHandle instance
exists(path) → bool
Check if path exists.
read_bytes(path) → bytes
Read file as bytes.
write_bytes(path, data)
Write bytes to file.
delete(path)
Delete file.
list_dir(path) → Iterator
List directory contents.
is_dir(path) → bool
Check if path is a directory.
is_file(path) → bool
Check if path is a file.
stat(path) → Any
Get file stats.
mkdir(path, parents=False, exist_ok=False)
Create a directory marker (empty blob with trailing slash).
glob(path, pattern) → Iterator
Find all paths matching pattern.
walk(path) → Iterator
Walk directory tree.
touch(path, exist_ok=True)
Create empty file or update metadata.
rename(src, dst)
Rename/move file.
rmdir(path)
Remove directory marker.
symlink_to(path, target)
Create symlink by storing target in metadata.
get_metadata(path) → dict
Get object metadata.
set_metadata(path, metadata)
Set object metadata.
rmtree(path, ignore_errors=False, onerror=None)
Remove directory and all its contents recursively.
copy(src, dst, follow_symlinks=True)
Copy file from src to dst.
copytree(src, dst, follow_symlinks=True)
Copy directory tree from src to dst recursively.
read_text(path, encoding='utf-8') → str
Read file as text.
write_text(path, data, encoding='utf-8')
Write text to file.
is_symlink(path)
Check if path is a symlink (has symlink metadata).
path(str) — Cloud path
True if path is a symlink
readlink(path)
Read symlink target from metadata.
path(str) — Cloud path
Symlink target path
panpath.clients.AsyncClient()
Base class for asynchronous cloud storage clients.
__aenter__()(AsyncClient) — Enter async context manager.</>__aexit__(exc_type,exc_val,exc_tb)— Exit async context manager.</>close()— Close any open connections/resources.</>copy(src,dst,follow_symlinks)— Copy file from src to dst.</>copytree(src,dst,follow_symlinks)— Copy directory tree from src to dst recursively.</>delete(path)— Delete file.</>exists(path)(bool) — Check if path exists.</>get_metadata(path)(dict) — Get object metadata.</>glob(path,pattern)(AsyncGenerator) — Find all paths matching pattern.</>is_dir(path)(bool) — Check if path is a directory.</>is_file(path)(bool) — Check if path is a file.</>is_symlink(path)(bool) — Check if path is a symlink (has symlink metadata).</>list_dir(path)(list) — List directory contents.</>mkdir(path,parents,exist_ok)— Create a directory marker (empty blob with trailing slash).</>open(path,mode,encoding,**kwargs)(Union) — Open file and return sync/async file handle.</>read_bytes(path)(bytes) — Read file as bytes.</>read_text(path,encoding)(str) — Read Azure blob as text.</>readlink(path)(str) — Read symlink target from metadata.</>rename(src,dst)— 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 object metadata.</>stat(path)(Any) — Get file stats.</>symlink_to(path,target)— Create symlink by storing target in metadata.</>touch(path,exist_ok)— Create empty file or update metadata.</>walk(path)(AsyncGenerator) — Walk directory tree.</>write_bytes(path,data)(int) — Write bytes to file.</>write_text(path,data,encoding)(int) — Write text to Azure blob.</>
open(path, mode='r', encoding=None, **kwargs)
Open file and return sync/async file handle.
path(str) — Cloud storage pathmode(str, optional) — File mode ('r', 'w', 'rb', 'wb', 'a', 'ab')encoding(Optional, optional) — Text encoding (for text modes)**kwargs(Any) — Additional arguments for specific implementations
SyncFileHandle/AsyncFileHandle instance
close()
Close any open connections/resources.
exists(path) → bool
Check if path exists.
read_bytes(path) → bytes
Read file as bytes.
write_bytes(path, data) → int
Write bytes to file.
delete(path)
Delete file.
list_dir(path) → list
List directory contents.
is_dir(path) → bool
Check if path is a directory.
is_file(path) → bool
Check if path is a file.
stat(path) → Any
Get file stats.
mkdir(path, parents=False, exist_ok=False)
Create a directory marker (empty blob with trailing slash).
glob(path, pattern) → AsyncGenerator
Find all paths matching pattern.
walk(path) → AsyncGenerator
Walk directory tree.
touch(path, exist_ok=True)
Create empty file or update metadata.
rename(src, dst)
Rename/move file.
rmdir(path)
Remove directory marker.
symlink_to(path, target)
Create symlink by storing target in metadata.
get_metadata(path) → dict
Get object metadata.
set_metadata(path, metadata)
Set object metadata.
rmtree(path, ignore_errors=False, onerror=None)
Remove directory and all its contents recursively.
copy(src, dst, follow_symlinks=True)
Copy file from src to dst.
copytree(src, dst, follow_symlinks=True)
Copy directory tree from src to dst recursively.
__aenter__() → AsyncClient
Enter async context manager.
__aexit__(exc_type, exc_val, exc_tb)
Exit async context manager.
read_text(path, encoding='utf-8') → str
Read Azure blob as text.
write_text(path, data, encoding='utf-8') → int
Write text to Azure blob.
is_symlink(path)
Check if path is a symlink (has symlink metadata).
path(str) — Cloud path
True if path is a symlink
readlink(path)
Read symlink target from metadata.
path(str) — Cloud path
Symlink target path
panpath.clients.AsyncFileHandle(client_factory, bucket, blob, prefix, mode='r', encoding=None, chunk_size=4096, upload_warning_threshold=100, upload_interval=1.0)
Base class for async file handles.
This abstract base class defines the interface for async file operations on cloud storage. Each cloud provider implements its own version using the provider's specific streaming capabilities.
closed(bool) — Check if file is closed.</>
__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.</>
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.
reset_stream()
Reset the underlying stream to the beginning.
__aenter__() → AsyncFileHandle
Enter async context manager.
__aexit__(exc_type, exc_val, exc_tb)
Exit async context manager.
read(size=-1)
Read and return up to size bytes/characters.
size(int, optional) — Number of bytes/chars to read (-1 for all)
Data read from file
readline(size=-1) → Union
Read and return one line from the file.
readlines() → List
Read and return all lines from the file.
write(data) → int
Write data to the file.
writelines(lines)
Write a list of lines to the file.
close()
Close the file and flush write buffer to cloud storage.
__aiter__() → AsyncFileHandle
Support async iteration over lines.
__anext__() → Union
Get next line in async iteration.
tell()
Return current stream position.
Current position in the file
seek(offset, whence=0)
Change stream position (forward seeking only).
offset(int) — Position offsetwhence(int, optional) — Reference point (0=start, 1=current, 2=end)
New absolute position
OSError— If backward seeking is attemptedValueError— 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
panpath.clients.SyncFileHandle(client, bucket, blob, prefix, mode='r', encoding=None, chunk_size=4096, upload_warning_threshold=100, upload_interval=1.0)
Base class for sync file handles.
This abstract base class defines the interface for sync file operations on cloud storage. Each cloud provider implements its own version using the provider's specific streaming capabilities.
closed(bool) — Check if file is closed.</>
__enter__()(SyncFileHandle) — Enter context manager.</>__exit__(exc_type,exc_val,exc_tb)— Exit async context manager.</>__iter__()(SyncFileHandle) — Support async iteration over lines.</>__next__()(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.</>
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.
reset_stream()
Reset the underlying stream to the beginning.
__enter__() → SyncFileHandle
Enter context manager.
__exit__(exc_type, exc_val, exc_tb)
Exit async context manager.
read(size=-1)
Read and return up to size bytes/characters.
size(int, optional) — Number of bytes/chars to read (-1 for all)
Data read from file
readline(size=-1) → Union
Read and return one line from the file.
readlines() → List
Read and return all lines from the file.
write(data) → int
Write data to the file.
writelines(lines)
Write a list of lines to the file.
close()
Close the file and flush write buffer to cloud storage.
__iter__() → SyncFileHandle
Support async iteration over lines.
__next__() → Union
Get next line in async iteration.
tell()
Return current stream position.
Current position in the file
seek(offset, whence=0)
Change stream position (forward seeking only).
offset(int) — Position offsetwhence(int, optional) — Reference point (0=start, 1=current, 2=end)
New absolute position
OSError— If backward seeking is attemptedValueError— 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