py-stream-zip


Namepy-stream-zip JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA stream-based ZIP file extractor in Python, inspired by node-stream-zip.
upload_time2025-02-17 06:47:01
maintainerNone
docs_urlNone
authorYour Name
requires_python>=3.6
licenseMIT License Copyright (c) 2023 Your Name Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # py-stream-zip

**py-stream-zip** is a Python library for extracting ZIP files using a stream-based approach. It provides efficient access to ZIP file entries without needing to load the entire file into memory. This package is inspired by and gives credit to [node-stream-zip](https://github.com/antelle/node-stream-zip).

## Features

- Stream-based extraction of ZIP files.
- Reads the central directory and processes entries on the fly.
- Simple, synchronous API for ease of integration.


## Installation

You can install **py-stream-zip** using pip:

```bash
pip install py-stream-zip
```

## Usage

Below is an example demonstrating how to extract a file from a ZIP archive:

```python
from py_stream_zip import StreamZip

zip_path = "path/to/archive.zip"
entry_name = "document.txt"  # The name of the file inside the ZIP

# Create a StreamZip instance (ensuring entries are stored for random access)
zip_archive = StreamZip(zip_path, store_entries=True)

try:
    # Extract and read the content of the specified entry.
    data = zip_archive.entry_data_sync(entry_name)
    print(data.decode("utf-8"))

    # or save to file as binary
    with open("document.txt", "wb") as f:
        f.write(data)

except Exception as ex:
    print(f"Error processing the ZIP file: {ex}")
finally:
    # Always close the archive to free the file handle.
    zip_archive.close()
```

For further reference, check out the provided [test_unzip.py](test_unzip.py) for a complete working example.

## Credits

**py-stream-zip** is inspired by [node-stream-zip](https://github.com/antelle/node-stream-zip). Special thanks to its developers for their contributions to the streaming ZIP extraction technique.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "py-stream-zip",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "David Bald <baldhumanity@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/1e/f4/89a2681a51a7365654eac50a240b0b4aaff55b041cd0854e9d3464e05a68/py_stream_zip-0.1.0.tar.gz",
    "platform": null,
    "description": "# py-stream-zip\n\n**py-stream-zip** is a Python library for extracting ZIP files using a stream-based approach. It provides efficient access to ZIP file entries without needing to load the entire file into memory. This package is inspired by and gives credit to [node-stream-zip](https://github.com/antelle/node-stream-zip).\n\n## Features\n\n- Stream-based extraction of ZIP files.\n- Reads the central directory and processes entries on the fly.\n- Simple, synchronous API for ease of integration.\n\n\n## Installation\n\nYou can install **py-stream-zip** using pip:\n\n```bash\npip install py-stream-zip\n```\n\n## Usage\n\nBelow is an example demonstrating how to extract a file from a ZIP archive:\n\n```python\nfrom py_stream_zip import StreamZip\n\nzip_path = \"path/to/archive.zip\"\nentry_name = \"document.txt\"  # The name of the file inside the ZIP\n\n# Create a StreamZip instance (ensuring entries are stored for random access)\nzip_archive = StreamZip(zip_path, store_entries=True)\n\ntry:\n    # Extract and read the content of the specified entry.\n    data = zip_archive.entry_data_sync(entry_name)\n    print(data.decode(\"utf-8\"))\n\n    # or save to file as binary\n    with open(\"document.txt\", \"wb\") as f:\n        f.write(data)\n\nexcept Exception as ex:\n    print(f\"Error processing the ZIP file: {ex}\")\nfinally:\n    # Always close the archive to free the file handle.\n    zip_archive.close()\n```\n\nFor further reference, check out the provided [test_unzip.py](test_unzip.py) for a complete working example.\n\n## Credits\n\n**py-stream-zip** is inspired by [node-stream-zip](https://github.com/antelle/node-stream-zip). Special thanks to its developers for their contributions to the streaming ZIP extraction technique.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2023 Your Name\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE. ",
    "summary": "A stream-based ZIP file extractor in Python, inspired by node-stream-zip.",
    "version": "0.1.0",
    "project_urls": {
        "Credits": "https://github.com/antelle/node-stream-zip",
        "Homepage": "https://github.com/baldhumanity/py-stream-zip",
        "Repository": "https://github.com/baldhumanity/py-stream-zip"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ba970b237a164c2b1a2148d399db77278e0abfbe0e36d3a734cef7527f1b0b29",
                "md5": "51834edbe36024b027f5de777177b09e",
                "sha256": "df0f47ded93cd074c4b21aae2cb815c67f776064e25c0b607c1981b6ff4d20ce"
            },
            "downloads": -1,
            "filename": "py_stream_zip-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "51834edbe36024b027f5de777177b09e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 13034,
            "upload_time": "2025-02-17T06:46:59",
            "upload_time_iso_8601": "2025-02-17T06:46:59.879740Z",
            "url": "https://files.pythonhosted.org/packages/ba/97/0b237a164c2b1a2148d399db77278e0abfbe0e36d3a734cef7527f1b0b29/py_stream_zip-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1ef489a2681a51a7365654eac50a240b0b4aaff55b041cd0854e9d3464e05a68",
                "md5": "55ec71ebb643ef06faf912d85999a395",
                "sha256": "62c2c8e91365dcb5779e89a473787715a3d2cc740879f6fb800673e66a01f8f0"
            },
            "downloads": -1,
            "filename": "py_stream_zip-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "55ec71ebb643ef06faf912d85999a395",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12317,
            "upload_time": "2025-02-17T06:47:01",
            "upload_time_iso_8601": "2025-02-17T06:47:01.825443Z",
            "url": "https://files.pythonhosted.org/packages/1e/f4/89a2681a51a7365654eac50a240b0b4aaff55b041cd0854e9d3464e05a68/py_stream_zip-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-17 06:47:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "antelle",
    "github_project": "node-stream-zip",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "py-stream-zip"
}
        
Elapsed time: 6.62981s