# 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
```python
>>> 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
```bash
$ 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
```bash
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "pyunixlzw",
"maintainer": "Justin Berthelot",
"docs_url": null,
"requires_python": ">3.6",
"maintainer_email": null,
"keywords": "compress, decompress, lzw, uncompress, unix",
"author": "Justin Berthelot",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/85/32/c4ae3df3ecf078e321fa429426d49e73c88ba6810c602d41ca4579cb9dad/pyunixlzw-1.0.0.0.tar.gz",
"platform": null,
"description": "# pyunixlzw\r\n**pyunixlzw** is a \"pure\" python3 implementation of the Unix compress/uncompress tool.\r\n\r\n## Usage\r\npyunixlzw comes with access to both a module and a script that serves as a semi-replacement for `(N)compress`.\r\n\r\n### Module\r\n```python\r\n>>> import pyunixlzw\r\n>>> print(pyunixlzw.compress(b'aaaaaaaaaa'))\r\nb'\\x1f\\x9d\\x90a\\x02\\n\\x1c\\x08'\r\n>>> print(pyunixlzw.decompress(b'\\x1f\\x9d\\x90a\\x02\\n\\x1c\\x08'))\r\nb'aaaaaaaaaa'\r\n```\r\n\r\n### Script\r\n```bash\r\n$ pyunixlzw -h\r\nusage: pyunixlzw [-h] [-d] [-c] [-b MAXBITS] [-f] [-v] [-V] file\r\n\r\nA pure-Python3 implementation of UNIX compress and decompress.\r\n\r\npositional arguments:\r\n file\r\n\r\noptions:\r\n -h, --help show this help message and exit\r\n -d, --decompress If given, decompression is done instead.\r\n -c, --stdout Write output on stdout, don't remove original.\r\n -b, --maxbits MAXBITS\r\n Parameter limits the max number of bits/code.\r\n -f, --force Forces output file to be generated, even if one already exists, and even if no space is saved\r\n by compressing.\r\n -v, --stats Write compression statistics.\r\n -V, --version Output version and author.\r\n$ \r\n```\r\n\r\n## Installation\r\n```bash\r\npip install pyunixlzw\r\n```\r\n\r\n# WARNING\r\nThe 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. \r\n\r\nThese 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. \r\n\r\nIf 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. \r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A pure-Python3 implementation of UNIX compress and decompress.",
"version": "1.0.0.0",
"project_urls": {
"Repository": "https://github.com/jbert1/pyunixlzw"
},
"split_keywords": [
"compress",
" decompress",
" lzw",
" uncompress",
" unix"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cdfb1d8d089d7dcecc1dc51b6634846bcf0a593900e05210df6a69bd23e0e2f5",
"md5": "bb981fd0c51e531bf2bf836998d546be",
"sha256": "797e3535af6b481e0fba63654b521961fbb3f266d297b85ac7676e92de8d3e8f"
},
"downloads": -1,
"filename": "pyunixlzw-1.0.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bb981fd0c51e531bf2bf836998d546be",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">3.6",
"size": 11107,
"upload_time": "2025-02-18T02:08:04",
"upload_time_iso_8601": "2025-02-18T02:08:04.777771Z",
"url": "https://files.pythonhosted.org/packages/cd/fb/1d8d089d7dcecc1dc51b6634846bcf0a593900e05210df6a69bd23e0e2f5/pyunixlzw-1.0.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8532c4ae3df3ecf078e321fa429426d49e73c88ba6810c602d41ca4579cb9dad",
"md5": "e1ab50dca4b9008bf42d89bea70b88cc",
"sha256": "0a0972ac661c8ad2c8472b5131ca52a5bedbfaafca0a487289e7a1c7c33c7299"
},
"downloads": -1,
"filename": "pyunixlzw-1.0.0.0.tar.gz",
"has_sig": false,
"md5_digest": "e1ab50dca4b9008bf42d89bea70b88cc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">3.6",
"size": 11112,
"upload_time": "2025-02-18T02:08:06",
"upload_time_iso_8601": "2025-02-18T02:08:06.608951Z",
"url": "https://files.pythonhosted.org/packages/85/32/c4ae3df3ecf078e321fa429426d49e73c88ba6810c602d41ca4579cb9dad/pyunixlzw-1.0.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-18 02:08:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jbert1",
"github_project": "pyunixlzw",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyunixlzw"
}