huffify


Namehuffify JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/munwriter/Huffify
SummarySimple Huffman algotithm implementation
upload_time2024-05-02 11:34:59
maintainerNone
docs_urlNone
authormunwriter
requires_python<4.0,>=3.12
licenseMIT
keywords huffman compression encoding decoding
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Huffify
![PyPI - Version](https://img.shields.io/pypi/v/huffify?style=for-the-badge&color=green)
![Static Badge](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)
![PyPI - Format](https://img.shields.io/pypi/format/huffify?style=for-the-badge)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/munwriter/Huffify/test-lint.yml?style=for-the-badge)


## Description
Huffify allows you to compress text using Huffman algorithm. Huffify focus on flexibility - you can choose various encoders, huffman tree nodes and file managers to rich the best compressing quality
> Historical note: The Huffman algorithm was developed by David A. Huffman in 1952. [Read more about David and his algorithm](https://ru.wikipedia.org/wiki/Код_Хаффмана)

## Usage
Basic usage
```python
from huffify import HuffmanCodec
from huffify.heapNodes import Node, LexicographicNode
from huffify.encoders import MVPEncoder

# You can use LexicographicNode that provide idempotent result and another encoder.
# Now this node and encoder set as default attributes 
codec = HuffmanCodec(node=Node, encoder=MVPEncoder)
message = "The sun shines bright today."

# Here is the "FinalDataSet", which can be saved as file
encoded_message = codec.encode(message)

# Also you can decode this "FinalDataSet" to get original message
decoded_message = codec.decode(encoded_message)
```
Advanced usage
```python
from huffify import Huffify
from huffify.fileManager import Picklefier

# You can pass preferred writing into file strategy
# It's only one yet and it thrown into Huffify as default strategy
file_compressor = Huffify(file_manager=Picklefier)

# You can save your compressed message into file
file_compressor.save(path="output", message="The sun shines bright today.")

# And also load and decompress it
decoded_message = file_compressor.load(path="output")

```
Watch encoding table
```python
from huffify import HuffmanCodec

codec = HuffmanCodec()
message = "The sun shines bright today."

# If you want get encoding table as dict
encoding_table = codec._get_encoding_table(message)

# Also you can print the encoding at representative view
codec.print_encoding_table(message)

```

## Installation
Using pip
```
pip install huffify
```
Using poetry
```
poetry add huffify
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/munwriter/Huffify",
    "name": "huffify",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": "huffman, compression, encoding, decoding",
    "author": "munwriter",
    "author_email": "glebvysokov3@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/74/c5/16b38de829f1de1d8a44622bd1d0f90fa31cfcef57633f99198b9aa690bb/huffify-0.2.0.tar.gz",
    "platform": null,
    "description": "# Huffify\n![PyPI - Version](https://img.shields.io/pypi/v/huffify?style=for-the-badge&color=green)\n![Static Badge](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)\n![PyPI - Format](https://img.shields.io/pypi/format/huffify?style=for-the-badge)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/munwriter/Huffify/test-lint.yml?style=for-the-badge)\n\n\n## Description\nHuffify allows you to compress text using Huffman algorithm. Huffify focus on flexibility - you can choose various encoders, huffman tree nodes and file managers to rich the best compressing quality\n> Historical note: The Huffman algorithm was developed by David A. Huffman in 1952. [Read more about David and his algorithm](https://ru.wikipedia.org/wiki/\u041a\u043e\u0434_\u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430)\n\n## Usage\nBasic usage\n```python\nfrom huffify import HuffmanCodec\nfrom huffify.heapNodes import Node, LexicographicNode\nfrom huffify.encoders import MVPEncoder\n\n# You can use LexicographicNode that provide idempotent result and another encoder.\n# Now this node and encoder set as default attributes \ncodec = HuffmanCodec(node=Node, encoder=MVPEncoder)\nmessage = \"The sun shines bright today.\"\n\n# Here is the \"FinalDataSet\", which can be saved as file\nencoded_message = codec.encode(message)\n\n# Also you can decode this \"FinalDataSet\" to get original message\ndecoded_message = codec.decode(encoded_message)\n```\nAdvanced usage\n```python\nfrom huffify import Huffify\nfrom huffify.fileManager import Picklefier\n\n# You can pass preferred writing into file strategy\n# It's only one yet and it thrown into Huffify as default strategy\nfile_compressor = Huffify(file_manager=Picklefier)\n\n# You can save your compressed message into file\nfile_compressor.save(path=\"output\", message=\"The sun shines bright today.\")\n\n# And also load and decompress it\ndecoded_message = file_compressor.load(path=\"output\")\n\n```\nWatch encoding table\n```python\nfrom huffify import HuffmanCodec\n\ncodec = HuffmanCodec()\nmessage = \"The sun shines bright today.\"\n\n# If you want get encoding table as dict\nencoding_table = codec._get_encoding_table(message)\n\n# Also you can print the encoding at representative view\ncodec.print_encoding_table(message)\n\n```\n\n## Installation\nUsing pip\n```\npip install huffify\n```\nUsing poetry\n```\npoetry add huffify\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple Huffman algotithm implementation",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/munwriter/Huffify",
        "Repository": "https://github.com/munwriter/Huffify"
    },
    "split_keywords": [
        "huffman",
        " compression",
        " encoding",
        " decoding"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d853832b00e639a8520df107b3d0397ca1d005df684fe2e7eb55f373d4a544d",
                "md5": "c482d94e6014ed926ca2f81bc35f7173",
                "sha256": "d12fd09a7b9d07f23512480e921bbe745bb638a035234788fbe2606798e8e4ed"
            },
            "downloads": -1,
            "filename": "huffify-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c482d94e6014ed926ca2f81bc35f7173",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 6643,
            "upload_time": "2024-05-02T11:34:57",
            "upload_time_iso_8601": "2024-05-02T11:34:57.212153Z",
            "url": "https://files.pythonhosted.org/packages/8d/85/3832b00e639a8520df107b3d0397ca1d005df684fe2e7eb55f373d4a544d/huffify-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74c516b38de829f1de1d8a44622bd1d0f90fa31cfcef57633f99198b9aa690bb",
                "md5": "540d3dfec7a1813dd4b14f9c04a44212",
                "sha256": "fafe0a28ac6522cf61366943b8e3afb05c6ed1a952a3ce1ef7781f45b40306f7"
            },
            "downloads": -1,
            "filename": "huffify-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "540d3dfec7a1813dd4b14f9c04a44212",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 5058,
            "upload_time": "2024-05-02T11:34:59",
            "upload_time_iso_8601": "2024-05-02T11:34:59.098392Z",
            "url": "https://files.pythonhosted.org/packages/74/c5/16b38de829f1de1d8a44622bd1d0f90fa31cfcef57633f99198b9aa690bb/huffify-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-02 11:34:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "munwriter",
    "github_project": "Huffify",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "huffify"
}
        
Elapsed time: 0.26617s