Skip to main content

miniuri: The Universal URI Parser

Project description

miniuri is a universal URI parser class.

Only 150 lines of Python (486 lines if you count unit tests).

Installation

pip install miniuri

What does it do?

The parser grants access to the following attributes:

foo://username:password@test.com:808/go/to/index.php?pet=cat&name=bam#eye
\_/   \_______________/ \______/ \_/       \___/ \_/ \_______________/\_/
 |           |             |      |          |    |       |            |
 |       userinfo       hostname  |          |    |      query   fragment
 |    \___________________________|/\________|____|_/
 |                  |             |      |   |    |
scheme          authority         |    path  |  extension
                                  |          |
                                 port     filename

Tutorial

This example shows how you can set and get any of the URI attributes:

>>> from miniuri import Uri
>>> u = Uri( "http://www.foxhop.net/samsung/HL-T5087SA/red-LED-failure" )
>>> u.uri = "https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5"
>>> print(u.uri)
'https://fox:pass@www.foxhop.net:81/path/filename.jpg?p=2#5'
>>> print(u.hostname)
'www.foxhop.net'
>>> print(u.scheme)
'https'
>>> u.username = 'max'
>>> print(u)
'https://max:pass@www.foxhop.net:81/path/filename.jpg?p=2#5'
>>> print(u.relative_uri)
'/path/filename.jpg?p=2#5'

How do I thank you?

You should follow me on http://twitter.com/russellbal

License

  • Public Domain

Public Revision Control

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

miniuri-1.1.0.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file miniuri-1.1.0.tar.gz.

File metadata

  • Download URL: miniuri-1.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for miniuri-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8e1cd7a6223abda90175706881685e87c71d499d806ed90743d76816f7cbc8ef
MD5 853897d88f11027ec46a41c2a825d7c3
BLAKE2b-256 ce52cf8f3be8880870330aa34b842f9c54be20dc8ea440b9b8895f4b925dc579

See more details on using hashes here.

Supported by

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