Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyunixlzw-1.0.0.0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyunixlzw-1.0.0.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

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

Hashes for pyunixlzw-1.0.0.0.tar.gz
Algorithm Hash digest
SHA256 0a0972ac661c8ad2c8472b5131ca52a5bedbfaafca0a487289e7a1c7c33c7299
MD5 e1ab50dca4b9008bf42d89bea70b88cc
BLAKE2b-256 8532c4ae3df3ecf078e321fa429426d49e73c88ba6810c602d41ca4579cb9dad

See more details on using hashes here.

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

Hashes for pyunixlzw-1.0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 797e3535af6b481e0fba63654b521961fbb3f266d297b85ac7676e92de8d3e8f
MD5 bb981fd0c51e531bf2bf836998d546be
BLAKE2b-256 cdfb1d8d089d7dcecc1dc51b6634846bcf0a593900e05210df6a69bd23e0e2f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page