🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

autoopen

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autoopen

Automatically compress or decompress files on open by filename.

pipPyPI
Version
0.1.0
Maintainers
1

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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts