huntZip
A lightweight Python module that provides a single, consistent API for compressing and extracting files across multiple archive formats. It automatically determines the appropriate compression method based on the file extension.
Supported Formats
| Format | Extension | Pack | Unpack | Backend |
|---|---|---|---|---|
| ZIP | .zip |
Yes | Yes | zipfile (built-in, with Zip64) |
| 7-Zip | .7z |
Yes | Yes | py7zr (external) |
| TAR | .tar |
Yes | Yes | tarfile (built-in) |
| Gzip TAR | .tar.gz |
Yes | Yes | tarfile + gzip (built-in) |
| Bzip2 TAR | .tar.bz2 |
Yes | Yes | tarfile + bz2 (built-in) |
| XZ TAR | .tar.xz |
Yes | Yes | tarfile + lzma (built-in) |
Prerequisites
The script uses built-in Python modules for most formats. Support for .7z archives requires the py7zr package.
pip install py7zr
Usage
Compression (pack)
The pack function handles both single files and directories. It recursively processes directories while preserving the relative internal structure.
from archiver import pack
# Compress a directory to ZIP
pack(source_path="data/my_folder", archive_name="backup.zip")
# Compress a directory to 7z
pack(source_path="data/my_folder", archive_name="archive.7z")
# Compress a single file to TAR.GZ
pack(source_path="data/document.pdf", archive_name="document.tar.gz")
Extraction (unpack)
The unpack function automatically detects the archive format and extracts its contents to the target directory. If the destination directory does not exist, it will be created.
from archiver import unpack
# Extract to the current directory
unpack(archive_path="backup.zip")
# Extract to a specific directory
unpack(archive_path="archive.7z", extract_to="extracted_data")
# Extract a compressed TAR archive
unpack(archive_path="document.tar.gz", extract_to="output/docs")
Error Handling
FileNotFoundError: Raised if the source path for archiving or the target archive for extraction does not exist.ValueError: Raised if the file extension is missing or not supported by the module.
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 huntzip-0.1.0.tar.gz.
File metadata
- Download URL: huntzip-0.1.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.18.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.13.7"},"installer":{"name":"hatch","version":"1.18.0"},"openssl_version":"OpenSSL 3.0.16 11 Feb 2025","python":"3.13.7","system":{"name":"Windows","release":"11"}} HTTPX2/2.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
460788b71991c7c11add8a79fc363870ea5500af564c48984ff0bf67271662fa
|
|
| MD5 |
442a3ba5c3ba8c53b76699c16f4a2841
|
|
| BLAKE2b-256 |
9135c893865d0ee647ceae81a07421423232469ed659ab650ec6270770e3adb7
|
File details
Details for the file huntzip-0.1.0-py3-none-any.whl.
File metadata
- Download URL: huntzip-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.18.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.13.7"},"installer":{"name":"hatch","version":"1.18.0"},"openssl_version":"OpenSSL 3.0.16 11 Feb 2025","python":"3.13.7","system":{"name":"Windows","release":"11"}} HTTPX2/2.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9166dbabe0465eae2fae718fcc67daa0387eae46fed25a11af078afa75b3eaab
|
|
| MD5 |
39f3214c74da80dce80c5dcca300d456
|
|
| BLAKE2b-256 |
b785a758dd7802a4a027bdb27cea323b5db36186832935531dfe1aaed8357832
|