shapelib.core.cloud.providers package#
Cloud storage providers for different protocols.
Submodules#
shapelib.core.cloud.providers.cloud_provider module#
Protocol defining the interface for cloud storage providers.
- class shapelib.core.cloud.providers.cloud_provider.CloudProvider(*args, **kwargs)[source]#
Bases:
ProtocolProtocol defining the interface for cloud storage providers.
Each cloud provider (S3, HTTPS, GCS, Azure) implements this interface to handle file operations for their specific storage system.
This follows the Strategy pattern, allowing GeoCloudFactory to delegate operations to the appropriate provider without conditional logic.
Examples
>>> class MyCloudProvider: ... def supports(self, cloud_path: CloudPath) -> bool: ... return cloud_path.scheme == "mycloud" ... ... def upload(self, source: Path, cloud_path: CloudPath) -> None: ... # Upload implementation ... ...
Big-O
All operations are O(n) where n is the file size.
- upload(source, cloud_path)[source]#
Upload a local file to cloud storage.
- Parameters:
- Raises:
FileNotFoundError – If the source file does not exist.
ConnectionError – If the upload fails.
PermissionError – If access is denied.
- Return type:
- download(cloud_path, destination)[source]#
Download a remote file to local storage.
- Parameters:
- Returns:
The path to the downloaded file.
- Return type:
- Raises:
FileNotFoundError – If the remote file does not exist.
ConnectionError – If the download fails.
PermissionError – If access is denied.
shapelib.core.cloud.providers.https_provider module#
HTTPS cloud storage provider for presigned URLs.
- class shapelib.core.cloud.providers.https_provider.HttpsProvider[source]#
Bases:
objectCloud provider for HTTPS URLs (including presigned URLs).
Handles file operations using the requests library for HTTP/HTTPS URLs. Works with presigned URLs from any cloud provider (AWS, GCS, Azure).
Examples
>>> provider = HttpsProvider() >>> provider.supports(CloudPath.from_string("https://example.com/file.fgb")) True
Big-O
All operations are O(n) where n is the file size.
- upload(source, cloud_path)[source]#
Upload a local file via HTTPS PUT (presigned URL).
- Parameters:
- Raises:
FileNotFoundError – If the source file does not exist.
ConnectionError – If the upload fails.
PermissionError – If access is denied (403).
- Return type:
- download(cloud_path, destination)[source]#
Download a file via HTTPS GET.
- Parameters:
- Returns:
The path to the downloaded file.
- Return type:
- Raises:
FileNotFoundError – If the remote file does not exist (404).
ConnectionError – If the download fails.
PermissionError – If access is denied (403).
shapelib.core.cloud.providers.s3_provider module#
AWS S3 cloud storage provider.
- class shapelib.core.cloud.providers.s3_provider.S3Provider[source]#
Bases:
objectCloud provider for AWS S3 storage.
Handles file operations using the boto3 library for s3:// protocol URLs.
Examples
>>> provider = S3Provider() >>> provider.supports(CloudPath.from_string("s3://bucket/file.fgb")) True
Big-O
All operations are O(n) where n is the file size.
- upload(source, cloud_path)[source]#
Upload a local file to S3.
- Parameters:
- Raises:
ImportError – If boto3 is not installed.
FileNotFoundError – If the source file does not exist.
ConnectionError – If the upload fails.
PermissionError – If access is denied.
- Return type:
- download(cloud_path, destination)[source]#
Download a file from S3.
- Parameters:
- Returns:
The path to the downloaded file.
- Return type:
- Raises:
ImportError – If boto3 is not installed.
FileNotFoundError – If the S3 object does not exist.
ConnectionError – If the download fails.
PermissionError – If access is denied.