Metadata-Version: 2.5
Name: huntzip
Version: 0.1.0
Summary: A fast, lightweight, and universal Python library for archiving and extracting files.
Requires-Python: >=3.8
Requires-Dist: py7zr>=1.1.3
Description-Content-Type: text/markdown

<p align="center">
  <img src="resources/icon.png" width="150" alt="huntZip">
  <br>
  <b>huntZip</b>
</p>

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.

```bash
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.

```python
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.

```python
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.
