Skip to main content

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)

Source distribution for superfile 0.0.7
File Size Uploaded
superfile-0.0.7.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for superfile 0.0.7
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page