Automatically compress or decompress files on open by filename.
Project description
autoopen
autoopen is a small drop-in replacement for the most common use cases of Python’s built-in open() function that will automatically handle compressed files based on the filename.
Usage
For example:
from autoopen import autoopen
filename = "example.txt.xz"
with autoopen(filename, "rt", encoding="utf-8") as file:
contents = file.read()
autoopen will check the given filename’s last suffix. If it indicates one of the supported compressors, the corresponding compressor or decompressor will be used, otherwise it falls back to built-in open.
Support for .gz, .bz2, .xz, .lzma, and .zst/.zstd is built-in (the latter requires the python-zstandard package). The special filename - indicates reading from stdin or writing to stdout.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autoopen-0.1.0.tar.gz.
File metadata
- Download URL: autoopen-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.17.0-1-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
771a62070ec5c9cc850209e278e2467c24bf2564a1426f300ab9b1da2add5186
|
|
| MD5 |
9f2288cf59a14cc2328ebc2f428b111e
|
|
| BLAKE2b-256 |
fafab81af60c4111ce7e81cbc3419edda5eae292aa9df5b547e39aa8836b6457
|
File details
Details for the file autoopen-0.1.0-py3-none-any.whl.
File metadata
- Download URL: autoopen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.17.0-1-amd64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b5f2d7d399f5b1801aa150aef90d883b3d83d3fa7adabc245068d5da8dbef4
|
|
| MD5 |
a4052dfabdd7f6e3ea9802d30362c7c8
|
|
| BLAKE2b-256 |
bcc1b668950a45e8a13569f37bdc0589a9346f64e533e0a09c838ac5a5264d7c
|