A pure-Python3 implementation of UNIX compress and decompress.
Project description
pyunixlzw
pyunixlzw is a "pure" python3 implementation of the Unix compress/uncompress tool.
Usage
pyunixlzw comes with access to both a module and a script that serves as a semi-replacement for (N)compress.
Module
>>> import pyunixlzw
>>> print(pyunixlzw.compress(b'aaaaaaaaaa'))
b'\x1f\x9d\x90a\x02\n\x1c\x08'
>>> print(pyunixlzw.decompress(b'\x1f\x9d\x90a\x02\n\x1c\x08'))
b'aaaaaaaaaa'
Script
$ pyunixlzw -h
usage: pyunixlzw [-h] [-d] [-c] [-b MAXBITS] [-f] [-v] [-V] file
A pure-Python3 implementation of UNIX compress and decompress.
positional arguments:
file
options:
-h, --help show this help message and exit
-d, --decompress If given, decompression is done instead.
-c, --stdout Write output on stdout, don't remove original.
-b, --maxbits MAXBITS
Parameter limits the max number of bits/code.
-f, --force Forces output file to be generated, even if one already exists, and even if no space is saved
by compressing.
-v, --stats Write compression statistics.
-V, --version Output version and author.
$
Installation
pip install pyunixlzw
WARNING
The compression function attempts to mirror (N)compress as close as possible, but there are times that a file compressed with compress will not match the output of a file compressed with pyunixlzw. This is due to logic that determines when to output a CLEAR code, which I was unable to replicate in my script.
These mismatched files can still be handled with both (N)compress and pyunixlzw; the primary difference is that (N)compress offers a much better compression ratio in much more efficient logic.
If anyone is able to integrate the CLEAR code logic, feel free to submit a note or pull request replacing the check_clear function contents in compress.py with the logic required to match.
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 pyunixlzw-1.0.0.0.tar.gz.
File metadata
- Download URL: pyunixlzw-1.0.0.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a0972ac661c8ad2c8472b5131ca52a5bedbfaafca0a487289e7a1c7c33c7299
|
|
| MD5 |
e1ab50dca4b9008bf42d89bea70b88cc
|
|
| BLAKE2b-256 |
8532c4ae3df3ecf078e321fa429426d49e73c88ba6810c602d41ca4579cb9dad
|
File details
Details for the file pyunixlzw-1.0.0.0-py3-none-any.whl.
File metadata
- Download URL: pyunixlzw-1.0.0.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
797e3535af6b481e0fba63654b521961fbb3f266d297b85ac7676e92de8d3e8f
|
|
| MD5 |
bb981fd0c51e531bf2bf836998d546be
|
|
| BLAKE2b-256 |
cdfb1d8d089d7dcecc1dc51b6634846bcf0a593900e05210df6a69bd23e0e2f5
|