urllib.request handler for scheme ppr: Python Package Resource files.
Project description
PprHandler
urllib.request.BaseHandler
for URLs with scheme ppr,
pointing to Python Package Resource files.
Using URL 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
as a scheme that uses netloc and relative URLs.
Installation
pip install ppr-handler
Usage
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
,
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'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ppr-handler-0.0.2.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for ppr_handler-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81dea824c0391dac3e2922d9c7feda09f97d4699d1e98070ed66a05cb1e64fa9 |
|
MD5 | aa1ec9a9ba5cb317ddf6b0dbcb556f4b |
|
BLAKE2b-256 | 73e1910b1fe3b3f0cd5b623409b93aa2206f014f0dd6da660dec531ea622f0fd |