Metadata-Version: 2.4
Name: lhafile
Version: 0.4.1
Summary: LHA archive support for Python
Home-page: https://github.com/FrodeSolheim/python-lhafile/
Download-URL: https://pypi.org/project/lhafile/
Author: Hidekazu Ohnishi
Author-email: the-o@neotitans.net
Maintainer: Frode Solheim
Maintainer-email: frode@solheim.dev
License: BSD
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: System :: Archiving
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: COPYING.txt
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: download-url
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: requires-python
Dynamic: summary

# LHA archive support for Python

The `lhafile` package reads LHA archives (`.lha`, `.lzh`), with an interface like the `zipfile` module in the standard library. It decompresses with `lzhlib`, an extension written in C.

```sh
pip install lhafile
```

```python
import lhafile

archive = lhafile.LhaFile("archive.lha")
for info in archive.infolist():
    if not info.is_dir():
        data = archive.read(info.filename)
```

## Features

- Archives with level 0, 1 and 2 headers, with members compressed with `-lh5-`, `-lh6-` or `-lh7-` or stored (`-lh0-`), and directory members (`-lhd-`).
- An interface like `zipfile`: `LhaFile` opens an archive from a path or a file object, and has `namelist()`, `infolist()` and `read(name)`. `is_lhafile()` tells whether a file is an archive it can read, and `BadLhafile` is raised for a broken one. `read()` checks the size and the CRC.
- An `LhaInfo` for each member, with `filename`, `directory`, `file_size`, `compress_size`, `compress_type`, `date_time`, `CRC`, `comment` and `is_dir()`.
- Names separate directories with `/` on every platform, as in `zipfile`, also in archives from MS-DOS and Windows, which use `\`.
- File comments, as Amiga archivers store them (file notes).
- The attribute byte, the OS ID and Amiga protection bits (`LhaInfo.attribute`, `os_id` and `amiga_protection`, as AmigaDOS lists them, such as `----rwed`; `amiga_protection()` for level 0 headers, which have no OS ID).
- Names and comments are decoded as ISO-8859-1.
- Wheels for CPython 3.9 and later on Linux, macOS and Windows, on x86 and ARM64. Elsewhere, pip builds it from the source distribution, which needs a C compiler.

It does not:

- write archives;
- read members in parts: `read()` returns a whole member;
- open archives with level 3 headers, or with members compressed in other ways (such as `-lh1-` or `-lh4-`);
- decode names in other encodings (such as the Shift JIS of Japanese archivers).

The changes in each release are in [CHANGELOG.md](https://github.com/FrodeSolheim/python-lhafile/blob/main/CHANGELOG.md).

## Origin

This project is an updated version of Hidekazu Ohnishi's lhafile (formerly at http://trac.neotitans.net/wiki/lhafile), which is no longer maintained.

## Licence

BSD 3-Clause, in [COPYING.txt](https://github.com/FrodeSolheim/python-lhafile/blob/main/COPYING.txt).
