Name | zipFly64 JSON |
Version |
1.1.1
JSON |
| download |
home_page | None |
Summary | Stream zip64 archives on the fly. |
upload_time | 2024-12-23 11:04:57 |
maintainer | None |
docs_url | None |
author | Pamparampampam |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2024 Pamparampam 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 |
zip64
zip
streaming
zipfly
zipfly64
|
VCS |
|
bugtrack_url |
|
requirements |
aiofiles
build
twine
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ZipFly
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/0-percent-optimized.svg" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://forthebadge.com/images/badges/gluten-free.png" alt="forthebadge"/></a>
<a href="http://forthebadge.com/"><img src="https://web.archive.org/web/20230604002050/https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg" alt="forthebadge"/></a>
<img src="https://img.shields.io/badge/ZIP64-Certified-lightGreen" alt="Build Status"/>
<img src="https://img.shields.io/badge/build-failing-red" alt="Build Status"/>
<img src="https://img.shields.io/badge/made with-hate-orange" alt="Build Status"/>
<img src="https://img.shields.io/badge/fuck-zip-green" alt="Build Status"/>
**Python library to construct a ZIP64 archive on the fly
without having to store the entire ZIP in
memory or disk. This is useful in memory-constrained environments, or when you would like to start
returning compressed data before you've even retrieved all the uncompressed data.
Generating ZIPs on-demand in a web server is a typical use case for zipFly.**
- No temporary files, data is streamed directly
- Support for **async** interface
- Calculates archive size before streaming even begins
- Supports `deflate` compression method
- Small memory usage, streaming is done using yield statement
- Archive structure is created on the fly, and all data can be created during stream
- Files included into archive can be generated on the fly using Python generators
- **Independent of the goofy 🤮🤮 python's standard ZipFile implementation**
- Only 1 dependency
- Automatic detection and changing of duplicate names
- `Zip64` format compatible files
This library is based upon [this library](https://github.com/kbbdy/zipstream) <sub>_(this library was a piece of work...)_<sub>
## How to install
pip install zipfly64
https://pypi.org/project/zipFly64
## Usage
```py
from zipFly import ZipFly, LocalFile, consts
# compression_method is optional, defaults to consts.NO_COMPRESSION
file1 = LocalFile(file_path='files/lqbfa61deebf1.mp4', compression_method=consts.NO_COMPRESSION) # or consts.COMPRESSION_DEFLATE
file2 = LocalFile(file_path='public/2ae9dcd01a3aa.mp4', name="files/my_file2.mp4") # override the file name
file3 = LocalFile(file_path='files/4shaw1dax4da.mp4', name="my_file3.mp4") # you control the directory path by specifying it in name
files = [file1, file2, file3]
zipFly = ZipFly(files)
# save to file, or do something else with the stream() generator
with open("out/file.zip", 'wb') as f_out:
for chunk in zipFly.stream():
f_out.write(chunk)
```
### Supports dynamically created files
```py
from zipFly import ZipFly, GenFile, LocalFile, consts
def file_generator():
yield b"uga buga"
yield b"a29jaGFtIGFsdGVybmF0eXdraQ=="
yield b"2137"
# size is optional, it allows to calculate the total size of the archive before any data is generated
# modification_time in epoch time, defaults to time.time()
file1 = GenFile(name="file.txt", generator=file_generator(), modification_time=time.time(), size=size, compression_method=consts.COMPRESSION_DEFLATE)
file2 = LocalFile(file_path='files/as61aade2ebfd.mp4', compression_method=consts.NO_COMPRESSION) # or consts.COMPRESSION_DEFLATE
files = [file1, file2]
zipFly = ZipFly(files)
archive_size = zipFly.calculate_archive_size() # raises ValueError if it can't calculate size
# for example you can set as content length in http response
response['Content-Length'] = archive_size
for chunk in zipFly.stream():
# do something
```
## Async interface
```py
import asyncio
from zipFly import ZipFly, LocalFile, consts, GenFile
# file_generator must be async! Local file async streaming is done with aiofiles library
file1 = GenFile(name="file.txt", generator=file_generator())
file2 = LocalFile(file_path='public/2ae9dcd01a3aa.mp4', name="files/my_file2.mp4")
files = [file1, file2]
zipFly = ZipFly(files)
async def save_zip_async():
with open("out/file.zip", 'wb') as f_out:
async for chunk in zipFly.async_stream():
f_out.write(chunk)
asyncio.run(save_zip_async())
```
### Other
Python is not optimized for async I/O operations, thus to speed up the async streaming the chunk_size is changed to 4MB, you can override this by passing chunksize as argument to LocalFile.
I created this library for my I Drive project.
If you have a different use case scenario, and LocalFile and GenFile are not enough, you can extend BaseFile and everything else should work out of the box.
### PS
I wholeheartedly hope everyone responsible for creating ZIP documentation gets slaughtered in the most gore and painful way 😊 (in game)
(pls redo ur [docs](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT))
Raw data
{
"_id": null,
"home_page": null,
"name": "zipFly64",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "zip64, zip, streaming, zipfly, zipfly64",
"author": "Pamparampampam",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/eb/76/a97364076431077be685f43f011443ec84be22df1bce562e37ffa8fba451/zipfly64-1.1.1.tar.gz",
"platform": null,
"description": "# ZipFly\n\n<a href=\"http://forthebadge.com/\"><img src=\"https://forthebadge.com/images/badges/0-percent-optimized.svg\" alt=\"forthebadge\"/></a>\n<a href=\"http://forthebadge.com/\"><img src=\"https://forthebadge.com/images/badges/gluten-free.png\" alt=\"forthebadge\"/></a>\n<a href=\"http://forthebadge.com/\"><img src=\"https://web.archive.org/web/20230604002050/https://forthebadge.com/images/badges/mom-made-pizza-rolls.svg\" alt=\"forthebadge\"/></a>\n\n<img src=\"https://img.shields.io/badge/ZIP64-Certified-lightGreen\" alt=\"Build Status\"/>\n<img src=\"https://img.shields.io/badge/build-failing-red\" alt=\"Build Status\"/>\n<img src=\"https://img.shields.io/badge/made with-hate-orange\" alt=\"Build Status\"/>\n<img src=\"https://img.shields.io/badge/fuck-zip-green\" alt=\"Build Status\"/>\n\n\n**Python library to construct a ZIP64 archive on the fly \nwithout having to store the entire ZIP in \nmemory or disk. This is useful in memory-constrained environments, or when you would like to start \nreturning compressed data before you've even retrieved all the uncompressed data. \nGenerating ZIPs on-demand in a web server is a typical use case for zipFly.**\n\n\n- No temporary files, data is streamed directly\n- Support for **async** interface \n- Calculates archive size before streaming even begins\n- Supports `deflate` compression method\n- Small memory usage, streaming is done using yield statement\n- Archive structure is created on the fly, and all data can be created during stream\n- Files included into archive can be generated on the fly using Python generators\n- **Independent of the goofy \ud83e\udd2e\ud83e\udd2e python's standard ZipFile implementation**\n- Only 1 dependency\n- Automatic detection and changing of duplicate names\n- `Zip64` format compatible files\n\n\nThis library is based upon [this library](https://github.com/kbbdy/zipstream) <sub>_(this library was a piece of work...)_<sub>\n\n## How to install\n pip install zipfly64\n\nhttps://pypi.org/project/zipFly64\n\n## Usage\n\n```py\nfrom zipFly import ZipFly, LocalFile, consts\n# compression_method is optional, defaults to consts.NO_COMPRESSION\nfile1 = LocalFile(file_path='files/lqbfa61deebf1.mp4', compression_method=consts.NO_COMPRESSION) # or consts.COMPRESSION_DEFLATE \nfile2 = LocalFile(file_path='public/2ae9dcd01a3aa.mp4', name=\"files/my_file2.mp4\") # override the file name\nfile3 = LocalFile(file_path='files/4shaw1dax4da.mp4', name=\"my_file3.mp4\") # you control the directory path by specifying it in name\n\nfiles = [file1, file2, file3]\n\nzipFly = ZipFly(files)\n\n# save to file, or do something else with the stream() generator\nwith open(\"out/file.zip\", 'wb') as f_out:\n for chunk in zipFly.stream():\n f_out.write(chunk)\n```\n\n### Supports dynamically created files\n```py\nfrom zipFly import ZipFly, GenFile, LocalFile, consts\n\n\ndef file_generator():\n yield b\"uga buga\"\n yield b\"a29jaGFtIGFsdGVybmF0eXdraQ==\"\n yield b\"2137\"\n \n# size is optional, it allows to calculate the total size of the archive before any data is generated\n# modification_time in epoch time, defaults to time.time()\nfile1 = GenFile(name=\"file.txt\", generator=file_generator(), modification_time=time.time(), size=size, compression_method=consts.COMPRESSION_DEFLATE)\nfile2 = LocalFile(file_path='files/as61aade2ebfd.mp4', compression_method=consts.NO_COMPRESSION) # or consts.COMPRESSION_DEFLATE \n\nfiles = [file1, file2]\n\nzipFly = ZipFly(files)\narchive_size = zipFly.calculate_archive_size() # raises ValueError if it can't calculate size\n\n# for example you can set as content length in http response\nresponse['Content-Length'] = archive_size\n\nfor chunk in zipFly.stream():\n # do something\n```\n\n## Async interface\n\n```py\nimport asyncio\nfrom zipFly import ZipFly, LocalFile, consts, GenFile\n# file_generator must be async! Local file async streaming is done with aiofiles library\nfile1 = GenFile(name=\"file.txt\", generator=file_generator())\nfile2 = LocalFile(file_path='public/2ae9dcd01a3aa.mp4', name=\"files/my_file2.mp4\")\n\nfiles = [file1, file2]\n\nzipFly = ZipFly(files)\n\nasync def save_zip_async():\n with open(\"out/file.zip\", 'wb') as f_out:\n async for chunk in zipFly.async_stream():\n f_out.write(chunk)\n\nasyncio.run(save_zip_async())\n```\n\n### Other\nPython is not optimized for async I/O operations, thus to speed up the async streaming the chunk_size is changed to 4MB, you can override this by passing chunksize as argument to LocalFile.\n\n\nI created this library for my I Drive project.\n\nIf you have a different use case scenario, and LocalFile and GenFile are not enough, you can extend BaseFile and everything else should work out of the box.\n\n\n\n### PS\n\nI wholeheartedly hope everyone responsible for creating ZIP documentation gets slaughtered in the most gore and painful way \ud83d\ude0a (in game)\n\n(pls redo ur [docs](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT))\n\n\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Pamparampam 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.",
"summary": "Stream zip64 archives on the fly.",
"version": "1.1.1",
"project_urls": {
"Github": "https://github.com/pam-param-pam/ZipFly"
},
"split_keywords": [
"zip64",
" zip",
" streaming",
" zipfly",
" zipfly64"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a4f43cf64c066230ab1a662c77c0cfc624c7f0a750ac1f9e7082750cfde4f0cb",
"md5": "bd790a9b02546f3b47ba46d614dcd619",
"sha256": "c5bfd4e1a0ff26784b07187af051567ba9e4388f6ad8c0ddf8d35b7deafd87f4"
},
"downloads": -1,
"filename": "zipFly64-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bd790a9b02546f3b47ba46d614dcd619",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12969,
"upload_time": "2024-12-23T11:04:55",
"upload_time_iso_8601": "2024-12-23T11:04:55.534963Z",
"url": "https://files.pythonhosted.org/packages/a4/f4/3cf64c066230ab1a662c77c0cfc624c7f0a750ac1f9e7082750cfde4f0cb/zipFly64-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "eb76a97364076431077be685f43f011443ec84be22df1bce562e37ffa8fba451",
"md5": "e0dae2e5690bbecfbba467baa0d4b410",
"sha256": "3baca6a9922a7b19d24e1f3eac5bc938354413d9dd7211d455609c5508fb0b2e"
},
"downloads": -1,
"filename": "zipfly64-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "e0dae2e5690bbecfbba467baa0d4b410",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 12803,
"upload_time": "2024-12-23T11:04:57",
"upload_time_iso_8601": "2024-12-23T11:04:57.547503Z",
"url": "https://files.pythonhosted.org/packages/eb/76/a97364076431077be685f43f011443ec84be22df1bce562e37ffa8fba451/zipfly64-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-23 11:04:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pam-param-pam",
"github_project": "ZipFly",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "aiofiles",
"specs": [
[
"==",
"24.1.0"
]
]
},
{
"name": "build",
"specs": [
[
"==",
"1.2.2"
]
]
},
{
"name": "twine",
"specs": [
[
"==",
"5.1.1"
]
]
}
],
"lcname": "zipfly64"
}