Skip to main content

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


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppr_handler-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file ppr-handler-0.0.2.tar.gz.

File metadata

  • Download URL: ppr-handler-0.0.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for ppr-handler-0.0.2.tar.gz
Algorithm Hash digest
SHA256 df104df0533acd7791a9580e033c95d7117db5a30adab91f194a587202e1a914
MD5 7777b5323dc8d25ad106c4fff2cea809
BLAKE2b-256 bb8ca00495069d57cc6ea2d9447eb57abc8add5d769c53461828c4cc649406a4

See more details on using hashes here.

File details

Details for the file ppr_handler-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ppr_handler-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for ppr_handler-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 81dea824c0391dac3e2922d9c7feda09f97d4699d1e98070ed66a05cb1e64fa9
MD5 aa1ec9a9ba5cb317ddf6b0dbcb556f4b
BLAKE2b-256 73e1910b1fe3b3f0cd5b623409b93aa2206f014f0dd6da660dec531ea622f0fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page