Skip to main content

A Unified File I/O Library for Python

Project description

⚓ Minato

Actions Status Python version License pypi version

A Unified File I/O Library for Python

Minato is a Python library that provides a unified and simple interface to work with local and remote files, as well as compressed and archived files. With Minato, you can seamlessly read and write files from various sources like local filesystem, HTTP(S), Amazon S3, and Google Cloud Storage. It also supports reading and writing compressed files such as gzip, bz2, and lzma, as well as directly accessing files inside archives like zip and tar.

One of Minato's key features is its built-in caching mechanism, which allows you to cache remote files locally, and manage the cache with a provided CLI. The cache is automatically updated based on ETag headers, ensuring that you always work with the latest version of the files.

Features

  • Unified file I/O for local and remote files (HTTP(S), S3, GCP)
  • Support for reading and writing compressed files (gzip, bz2, lzma)
  • Direct access to files inside archives (zip, tar)
  • Local caching of remote files with cache management CLI
  • Automatic cache updates based on ETag headers

Installation

Install Minato using pip:

pip install minato       # minimal installation for only local/http(s) file I/O
pip install minato[s3]   # for Amazon S3
pip install minato[gcp]  # for Google Cloud Storage
pip install minato[all]  # for all supported file I/O

Usage

Quick Start

Here's a simple example demonstrating how to read and write files on online storage:

import minato

# Write a file to an S3 bucket
s3_path = "s3://your_bucket/path/to/file"
with minato.open(s3_path, "w") as f:
    f.write("Create a new file on AWS S3!")

Access cached online resources in local storage:

# Cache a remote file and get its local path
remote_path = "http://example.com/path/to/archive.zip!inner/path/to/file"
local_filename = minato.cached_path(remote_path)

Access files inside archives like zip by connecting the archive path and inner file path with an exclamation mark (!) like above.

Automatically decompress files with gzip / lzma / bz2 compression:

with minato.open("data.txt.gz", "rt", decompress=True) as f:
    content = f.read()

In the example above, Minato will automatically detect the file format based on the file's content or filename and decompress the file accordingly.

Cache Management

 poetry run minato --help
usage: minato

positional arguments:
  {cache,list,remove,update}
    cache               cache remote file and return cached local file path
    list                show list of cached files
    remove              remove cached files
    update              update cached files

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minato-0.11.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

minato-0.11.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file minato-0.11.0.tar.gz.

File metadata

  • Download URL: minato-0.11.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.8.2 Linux/5.15.0-1036-azure

File hashes

Hashes for minato-0.11.0.tar.gz
Algorithm Hash digest
SHA256 2891e46697c17de10917c55f9a60ac1db385bb74691c8a5bfbef0c32d254bce7
MD5 5c91c058260ac91f3ecfd1c37a9efd59
BLAKE2b-256 c93b41aa2cb0f2f6e2e133c167baec01c74bf639188bad4c047f004596389db4

See more details on using hashes here.

File details

Details for the file minato-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: minato-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.8.2 Linux/5.15.0-1036-azure

File hashes

Hashes for minato-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c5422a7cd617221e09d13140a8f7454d1ce1068e01cbcd54814fde99da92721
MD5 d8580015c8747cc1d8af9113e0cbf599
BLAKE2b-256 3a54377522d91a6390cc1a280c584510d8ca10bc2f24ef49008efac702a3ae26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page