ppr-handler


Nameppr-handler JSON
Version 0.0.2 PyPI version JSON
download
home_page
Summaryurllib.request handler for scheme ppr: Python Package Resource files.
upload_time2023-10-22 14:41:00
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT License Copyright (c) 2023 Filip Thyssen 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 ppr urllib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PprHandler

[`urllib.request.BaseHandler`](https://docs.python.org/3/library/urllib.request.html#urllib.request.BaseHandler)
for URLs with scheme *ppr*,
pointing to Python Package Resource files.

Using [URL](https://datatracker.ietf.org/doc/html/rfc3986#section-3) terminology,
the URL consists of

- a scheme: *ppr*
- an authority: module name
- a path: package resource file path

for example
`ppr://ppr_handler/py.typed`.

It also registers *ppr* with [`urllib.parse`](https://docs.python.org/3/library/urllib.parse.html)
as a scheme that uses netloc and relative URLs.

## Installation

```sh
pip install ppr-handler
```

## Usage

```py
import ppr_handler
from urllib.request import build_opener

opener = build_opener(ppr_handler.PprHandler())
# or: opener = ppr_handler.build_opener()

with opener.open("ppr://ppr_handler/py.typed") as file:
    print(file.read())
    # b'# Marker file for PEP 561.\n'
```

or, for global use with `urllib.request`,

```py
import ppr_handler
from urllib.request import build_opener, install_opener, urlopen

install_opener(build_opener(ppr_handler.PprHandler()))

with urlopen("ppr://ppr_handler/py.typed") as file:
    print(file.read())
    # b'# Marker file for PEP 561.\n' 
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ppr-handler",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "ppr,urllib",
    "author": "",
    "author_email": "Filip Thyssen <filip.thyssen@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bb/8c/a00495069d57cc6ea2d9447eb57abc8add5d769c53461828c4cc649406a4/ppr-handler-0.0.2.tar.gz",
    "platform": null,
    "description": "# PprHandler\n\n[`urllib.request.BaseHandler`](https://docs.python.org/3/library/urllib.request.html#urllib.request.BaseHandler)\nfor URLs with scheme *ppr*,\npointing to Python Package Resource files.\n\nUsing [URL](https://datatracker.ietf.org/doc/html/rfc3986#section-3) terminology,\nthe URL consists of\n\n- a scheme: *ppr*\n- an authority: module name\n- a path: package resource file path\n\nfor example\n`ppr://ppr_handler/py.typed`.\n\nIt also registers *ppr* with [`urllib.parse`](https://docs.python.org/3/library/urllib.parse.html)\nas a scheme that uses netloc and relative URLs.\n\n## Installation\n\n```sh\npip install ppr-handler\n```\n\n## Usage\n\n```py\nimport ppr_handler\nfrom urllib.request import build_opener\n\nopener = build_opener(ppr_handler.PprHandler())\n# or: opener = ppr_handler.build_opener()\n\nwith opener.open(\"ppr://ppr_handler/py.typed\") as file:\n    print(file.read())\n    # b'# Marker file for PEP 561.\\n'\n```\n\nor, for global use with `urllib.request`,\n\n```py\nimport ppr_handler\nfrom urllib.request import build_opener, install_opener, urlopen\n\ninstall_opener(build_opener(ppr_handler.PprHandler()))\n\nwith urlopen(\"ppr://ppr_handler/py.typed\") as file:\n    print(file.read())\n    # b'# Marker file for PEP 561.\\n' \n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Filip Thyssen  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": "urllib.request handler for scheme ppr: Python Package Resource files.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/fthyssen/ppr-handler",
        "Repository": "https://github.com/fthyssen/ppr-handler"
    },
    "split_keywords": [
        "ppr",
        "urllib"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73e1910b1fe3b3f0cd5b623409b93aa2206f014f0dd6da660dec531ea622f0fd",
                "md5": "aa1ec9a9ba5cb317ddf6b0dbcb556f4b",
                "sha256": "81dea824c0391dac3e2922d9c7feda09f97d4699d1e98070ed66a05cb1e64fa9"
            },
            "downloads": -1,
            "filename": "ppr_handler-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa1ec9a9ba5cb317ddf6b0dbcb556f4b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4422,
            "upload_time": "2023-10-22T14:40:59",
            "upload_time_iso_8601": "2023-10-22T14:40:59.404546Z",
            "url": "https://files.pythonhosted.org/packages/73/e1/910b1fe3b3f0cd5b623409b93aa2206f014f0dd6da660dec531ea622f0fd/ppr_handler-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb8ca00495069d57cc6ea2d9447eb57abc8add5d769c53461828c4cc649406a4",
                "md5": "7777b5323dc8d25ad106c4fff2cea809",
                "sha256": "df104df0533acd7791a9580e033c95d7117db5a30adab91f194a587202e1a914"
            },
            "downloads": -1,
            "filename": "ppr-handler-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7777b5323dc8d25ad106c4fff2cea809",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5604,
            "upload_time": "2023-10-22T14:41:00",
            "upload_time_iso_8601": "2023-10-22T14:41:00.720671Z",
            "url": "https://files.pythonhosted.org/packages/bb/8c/a00495069d57cc6ea2d9447eb57abc8add5d769c53461828c4cc649406a4/ppr-handler-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-22 14:41:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fthyssen",
    "github_project": "ppr-handler",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ppr-handler"
}
        
Elapsed time: 0.13100s