Superfile
Simple Python file-like interface for cloud block storage. This is unlikely to be the most performant way do I/O with data from block storage, but it provides a uniform, simple API that can be used across multiple cloud block storage providers such as Google Cloud Storage, Amazon S3 and Azure Blob Storage.
Simple Usage
Importing the main module:
import superfile
Reading a local file:
with superfile.open('my/local/path', 'r') as f:
contents = f.read()
Reading a text file:
with superfile.open('gs://my_bucket_name/file.txt', 'r') as f:
text = f.read()
Reading a binary file:
with superfile.open('gs://my_bucket_name/file.ext', 'rb') as f:
data = f.read()
Writing a text file:
text = 'hello world'
with superfile.open('gs://my_bucket_name/file.txt', 'w') as f:
f.write(text)
Writing a binary file:
data = b'hello world'
with superfile.open('gs://my_bucket_name/file.txt', 'wb') as f:
f.write(data)
Listing all files in a bucket:
fnames = list(superfile.list('gs://my_bucket_name'))
Listing files with a prefix from a bucket:
prefix = 'abc'
fnames = list(superfile.list(f'gs://my_bucket_name/{prefix}'))
Advanced Usage
Reading a file from GCS and providing auth credentials:
import superfile
from google.oauth2 import service_account
fpath = 'gs://my_bucket_name/file.txt'
creds = service_account.Credentials.from_service_account_file('/path/to/key.json')
with superfile.open(
path=fpath,
mode='r',
# All init_kwargs are passed to google.cloud.storage.Client.__init__().
init_kwargs=dict(credentials=creds),
# All open_kwargs are passed to google.cloud.storage.Blob.open().
open_kwargs=dict(errors='strict'),
) as f:
...
Reading a file from S3 and providing endpoint URL:
import superfile
fpath = 's3://my_bucket_name/file.txt'
endpoint_url = 'https://example.com'
with superfile.open(
path=fpath,
mode='r',
# All init_kwargs are passed to boto3.client().
init_kwargs=dict(endpoint_url=endpoint_url),
# All open_kwargs are passed to boto3.client.get_object() or boto3.client.put_object().
open_kwargs=dict(VersionId='...'),
) as f:
...
Release files for superfile 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| superfile-0.0.7.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| superfile-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.8 kB
Release files / superfile-0.0.7.tar.gz
| Download URL | superfile-0.0.7.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77bf217356ca446b94ee658cd17c9dfc774c652bf811d7df9e187bed80aa1748
|
|
BLAKE2b-256 checksum How to use checksums |
a723e5611f51c68d5e3d519bdb7d043a3981fab56cca5ec6b7588f8a8105d6d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / superfile-0.0.7-py3-none-any.whl
| Download URL | superfile-0.0.7-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f62f32c4e82e3d03ac57b1e4f8632896f472e8b3988c23959553de7ef2cba31
|
|
BLAKE2b-256 checksum How to use checksums |
738d51d6366eb3198a6523417f2dae158347b95f369b303970384461ae6cf026
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|