shapelib.core.cloud package#
Cloud storage infrastructure for remote file operations.
Subpackages#
- shapelib.core.cloud.handlers package
- Submodules
- shapelib.core.cloud.handlers.remote_flatgeobuf_handler module
- shapelib.core.cloud.handlers.remote_geojson_handler module
- shapelib.core.cloud.handlers.remote_geopackage_handler module
- shapelib.core.cloud.handlers.remote_handler module
- shapelib.core.cloud.handlers.remote_kml_handler module
- shapelib.core.cloud.handlers.remote_shapefile_handler module
- shapelib.core.cloud.handlers.remote_spatialite_handler module
- shapelib.core.cloud.providers package
- shapelib.core.cloud.writers package
Submodules#
shapelib.core.cloud.cloud_path module#
Value Object for parsing and representing cloud/local file paths.
- class shapelib.core.cloud.cloud_path.CloudPath(raw_path, scheme, host, path, extension, query, _REMOTE_SCHEMES=frozenset({'az', 'gs', 'http', 'https', 's3'}))[source]#
Bases:
objectImmutable Value Object representing a file path (local or remote).
This class parses URLs and local paths to extract scheme, host, path, and file extension. It handles query strings in URLs (e.g., AWS presigned URLs) correctly by extracting the extension from the path component only.
- Parameters:
- Variables:
raw_path (
str) – The original path or URL as provided.scheme (
str) – The URL scheme (e.g., ‘https’, ‘s3’, ‘gs’, ‘file’, or empty for local).host (
str) – The host/bucket name for remote URLs, empty for local paths.path (
str) – The path component (without query string).extension (
str) – The file extension (e.g., ‘.fgb’, ‘.shp’).query (
str) – The query string component (for presigned URLs).
Examples
Parse a presigned S3 URL:
>>> cloud_path = CloudPath.from_string( ... "https://bucket.s3.amazonaws.com/file.fgb?X-Amz-Signature=..." ... ) >>> cloud_path.extension '.fgb' >>> cloud_path.is_remote True
Parse a local path:
>>> local_path = CloudPath.from_string("/home/user/data.shp") >>> local_path.is_remote False
Big-O
O(n) where n is the length of the path string.
- classmethod from_string(path)[source]#
Create a CloudPath from a string or Path object.
- Parameters:
- Returns:
A new CloudPath instance with parsed components.
- Return type:
- Raises:
ValueError – If the path is empty or None.