{ "info": { "author": "Giuseppe Tribulato", "author_email": "gtsystem@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "# remotezip\n\n[![Build Status](https://travis-ci.org/gtsystem/python-remotezip.svg?branch=master)](https://travis-ci.org/gtsystem/python-remotezip)\n\nThis module provides a way to access single members of a zip file archive without downloading the full content from a remote web server. For this library to work, the web server hosting the archive needs to support the [range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests) header. \n\n## Installation\n\n`pip install remotezip`\n\n## Usage\n\n### Initialization\n\n`RemoteZip(url, ...)`\n\nTo download the content, this library rely on the `requests` module. The constructor interface matches the function `requests.get` module.\n\n* **url**: Url where the zip file is located *(required)*.\n* **auth**: authentication credentials.\n* **headers**: headers to pass to the request.\n* **timeout**: timeout for the request.\n* **verify**: enable/disable certificate verification or set custom certificates location.\n* ... Please look at the [requests](http://docs.python-requests.org/en/master/user/quickstart/#make-a-request) documentation for futher usage details.\n* **initial\\_buffer\\_size**: How much data (in bytes) to fetch during the first connection to download the zip file central directory. If your zip file conteins a lot of files, would be a good idea to increase this parameter in order to avoid the need for further remote requests. *Default: 64kb*.\n\n### Class Interface\n\n`RemoteZip` is a subclass of the python standard library class `zipfile.ZipFile`, so it supports all its read methods:\n\n* `RemoteZip.close()`\n* `RemoteZip.getinfo(name)`\n* `RemoteZip.extract(member[, path[, pwd]])`\n* `RemoteZip.extractall([path[, members[, pwd]]])`\n* `RemoteZip.infolist()`\n* `RemoteZip.namelist()`\n* `RemoteZip.open(name[, mode[, pwd]])`\n* `RemoteZip.printdir()`\n* `RemoteZip.read(name[, pwd])`\n* `RemoteZip.testzip()`\n* `RemoteZip.filename`\n* `RemoteZip.debug`\n* `RemoteZip.comment`\n\nPlease look at the [zipfile](https://docs.python.org/3/library/zipfile.html#zipfile-objects) documentation for usage details.\n\n\n**NOTE**: `extractall()` and `testzip()` require to access the full content of the archive. If you need to use such methods, a full download of it would be probably more efficient.\n\n### Examples\n\n#### List members in archive\n\nPrint all members part of the archive:\n\n```python\nfrom remotezip import RemoteZip\n\nwith RemoteZip('http://.../myfile.zip') as zip:\n\tfor zip_info in zip.infolist():\n\t print(zip_info.name)\n```\n\n\n#### Download a member\nThe following example will extract the file `somefile.txt` from the archive stored at the url `http://.../myfile.zip`.\n\n```python\nfrom remotezip import RemoteZip\n\nwith RemoteZip('http://.../myfile.zip') as zip:\n\tzip.extract('somefile.txt')\n```\n\n#### S3 example\n\nIf you are trying to download a member from a zip archive hosted on S3 you can use the [aws-requests-auth](https://github.com/DavidMuller/aws-requests-auth) library for that as follow: \n\n```python\nfrom aws_requests_auth.boto_utils import BotoAWSRequestsAuth\nfrom hashlib import sha256\n\nauth = BotoAWSRequestsAuth(\n aws_host='s3-eu-west-1.amazonaws.com',\n aws_region='eu-west-1',\n aws_service='s3'\n)\nheaders = {'x-amz-content-sha256': sha256('').hexdigest()}\nurl = \"https://s3-eu-west-1.amazonaws.com/.../file.zip\"\n\nwith RemoteZip(url, auth=auth, headers=headers) as z: \n zip.extract('somefile.txt')\n```\n\n## Command line tool\n\nA simple command line tool is included in this distribution.\n\n```\nusage: remotezip [-h] [-l] [-d DIR] url [filename [filename ...]]\n\nUnzip remote files\n\npositional arguments:\n url Url of the zip archive\n filename File to extract\n\noptional arguments:\n -h, --help show this help message and exit\n -l, --list List files in the archive\n -d DIR, --dir DIR Extract directory, default current directory\n```\n\n#### Example\n\n```\n$ remotezip -l \"http://thematicmapping.org/downloads/TM_WORLD_BORDERS-0.3.zip\"\n Length DateTime Name\n-------- ------------------- ------------------------\n 2962 2008-07-30 13:58:46 Readme.txt\n 24740 2008-07-30 12:16:46 TM_WORLD_BORDERS-0.3.dbf\n 145 2008-03-12 13:11:54 TM_WORLD_BORDERS-0.3.prj\n 6478464 2008-07-30 12:16:46 TM_WORLD_BORDERS-0.3.shp\n 2068 2008-07-30 12:16:46 TM_WORLD_BORDERS-0.3.shx\n\n$ remotezip \"http://thematicmapping.org/downloads/TM_WORLD_BORDERS-0.3.zip\" Readme.txt\nExtracting Readme.txt...\n```\n\n## How it works\n\nThis module uses the `zipfile.ZipFile` class under the hood to decode the zip file format. The `ZipFile` class is initialized with a file like object that will perform transparently the remote queries.\n\nThe zip format is composed by the content of each compressed member followed by the central directory.\n\nHow many requests will this module perform to download a member?\n\n* If the full archive content is smaller than **initial\\_buffer\\_size**, only one request will be needed.\n* Normally two requests are needed, one to download the central directory and one to download the archive member.\n* If the central directory is bigger than **initial\\_buffer\\_size**, a third request will be required.\n\n## Alternative modules\n\nThere is a similar module available for python [pyremotezip](https://github.com/fcvarela/pyremotezip).\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gtsystem/python-remotezip", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "remotezip", "package_url": "https://pypi.org/project/remotezip/", "platform": "", "project_url": "https://pypi.org/project/remotezip/", "project_urls": { "Homepage": "https://github.com/gtsystem/python-remotezip" }, "release_url": "https://pypi.org/project/remotezip/0.9.2/", "requires_dist": [ "requests", "tabulate" ], "requires_python": "", "summary": "Access zip file content hosted remotely without downloading the full file.", "version": "0.9.2" }, "last_serial": 3816669, "releases": { "0.9.1": [ { "comment_text": "", "digests": { "md5": "0c1d614d1f9443011a0719604d80bd56", "sha256": "94d771042db8c556b580ae14a009eee5179bfa8d2f0d3d61c96d2f01631324a0" }, "downloads": -1, "filename": "remotezip-0.9.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0c1d614d1f9443011a0719604d80bd56", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5780, "upload_time": "2018-04-28T10:55:56", "url": "https://files.pythonhosted.org/packages/2c/3d/51b0aedd8cc715220409eefb9c11a6142956c8966123fd385e7fcd338234/remotezip-0.9.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1dd2383b787ca641d3568eb29997f9b4", "sha256": "965460ecb2466bec82cba50c46d740c665a1b495b8416afdab11fe5cce67e2ca" }, "downloads": -1, "filename": "remotezip-0.9.1.tar.gz", "has_sig": false, "md5_digest": "1dd2383b787ca641d3568eb29997f9b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5648, "upload_time": "2018-04-28T10:55:57", "url": "https://files.pythonhosted.org/packages/76/a9/6c6957f04e59398c237018a7631ffb0d4a44646cdf087590854e21ea757c/remotezip-0.9.1.tar.gz" } ], "0.9.2": [ { "comment_text": "", "digests": { "md5": "0a09724a4fcd954ce9dc5f1511704ebb", "sha256": "d2aa5eb7ad40e3a60c20c226141859278be19ba07023f49c42abd0e88dc06347" }, "downloads": -1, "filename": "remotezip-0.9.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0a09724a4fcd954ce9dc5f1511704ebb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5779, "upload_time": "2018-04-28T10:57:44", "url": "https://files.pythonhosted.org/packages/17/92/57938dea74ff6aa66cf3aa8db6ac7cbd16f3297fe1768e5187bbfb3f1d65/remotezip-0.9.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "44afb39c6702dcc276aac70310568ded", "sha256": "fd5a310436ecc6e1593fedbf8b0509e9f6fa013c8455a9645fcab46b5d511e91" }, "downloads": -1, "filename": "remotezip-0.9.2.tar.gz", "has_sig": false, "md5_digest": "44afb39c6702dcc276aac70310568ded", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5640, "upload_time": "2018-04-28T10:57:45", "url": "https://files.pythonhosted.org/packages/8a/2e/630ad96d01e8434c671cc8bfc60e255b4bbac43230983bbc341ad9f0304b/remotezip-0.9.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0a09724a4fcd954ce9dc5f1511704ebb", "sha256": "d2aa5eb7ad40e3a60c20c226141859278be19ba07023f49c42abd0e88dc06347" }, "downloads": -1, "filename": "remotezip-0.9.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0a09724a4fcd954ce9dc5f1511704ebb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5779, "upload_time": "2018-04-28T10:57:44", "url": "https://files.pythonhosted.org/packages/17/92/57938dea74ff6aa66cf3aa8db6ac7cbd16f3297fe1768e5187bbfb3f1d65/remotezip-0.9.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "44afb39c6702dcc276aac70310568ded", "sha256": "fd5a310436ecc6e1593fedbf8b0509e9f6fa013c8455a9645fcab46b5d511e91" }, "downloads": -1, "filename": "remotezip-0.9.2.tar.gz", "has_sig": false, "md5_digest": "44afb39c6702dcc276aac70310568ded", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5640, "upload_time": "2018-04-28T10:57:45", "url": "https://files.pythonhosted.org/packages/8a/2e/630ad96d01e8434c671cc8bfc60e255b4bbac43230983bbc341ad9f0304b/remotezip-0.9.2.tar.gz" } ] }