Skip to main content

RFC 3986 compliant, Unicode-aware, scheme-agnostic replacement for urlparse

Project description

This module defines RFC 3986 compliant replacements for the most commonly used functions of the Python 2.7 Standard Library urlparse and Python 3 urllib.parse modules.

>>> from uritools import urisplit, uriunsplit, urijoin, uridefrag
>>> parts = urisplit('foo://user@example.com:8042/over/there?name=ferret#nose')
>>> parts
SplitResultString(scheme='foo', authority='user@example.com:8042',
                  path='/over/there', query='name=ferret', fragment='nose')
>>> parts.scheme
'foo'
>>> parts.authority
'user@example.com:8042'
>>> parts.userinfo
'user'
>>> parts.host
'example.com'
>>> parts.port
'8042'
>>> uriunsplit(parts[:3] + ('name=swallow&type=African', 'beak'))
'foo://user@example.com:8042/over/there?name=swallow&type=African#beak'
>>> urijoin('http://www.cwi.nl/~guido/Python.html', 'FAQ.html')
'http://www.cwi.nl/~guido/FAQ.html'
>>> uridefrag('http://pythonhosted.org/uritools/index.html#constants')
DefragResult(uri='http://pythonhosted.org/uritools/index.html',
             fragment='constants')
>>> urisplit('http://www.xn--lkrbis-vxa4c.at/').gethost(encoding='idna')
'www.ölkürbis.at'

For various reasons, the Python 2 urlparse module is not compliant with current Internet standards, does not include Unicode support, and is generally unusable with proprietary URI schemes. Python 3’s urllib.parse improves on Unicode support, but the other issues still remain. As stated in Lib/urllib/parse.py:

RFC 3986 is considered the current standard and any future changes
to urlparse module should conform with it.  The urlparse module is
currently not entirely compliant with this RFC due to defacto
scenarios for parsing, and for backward compatibility purposes,
some parsing quirks from older RFCs are retained.

This module aims to provide fully RFC 3986 compliant replacements for some commonly used functions found in urlparse, plus additional functions for conveniently composing URIs from their individual components.

Installation

Install uritools using pip:

pip install uritools

Project Resources

Latest PyPI version Number of PyPI downloads Travis CI build status Test coverage

License

Copyright (c) 2014 Thomas Kemmer.

Licensed under the MIT License.

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

uritools-0.11.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

uritools-0.11.0-py2.py3-none-any.whl (15.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file uritools-0.11.0.tar.gz.

File metadata

  • Download URL: uritools-0.11.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for uritools-0.11.0.tar.gz
Algorithm Hash digest
SHA256 bfed47551e0715b5a64f422ce2f8050456a6532099cc1c66ba3c8180d36d5618
MD5 2a0e7a315135b2149734652f4d0b6c27
BLAKE2b-256 1a8c68543e3d3c5b3f097af9eb9385ab00226d43b51aaddd5b048e56afe151ea

See more details on using hashes here.

File details

Details for the file uritools-0.11.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for uritools-0.11.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 847633e9eb55c542f1dd7ea0ae94622e7a170c786a666e9e5dc010d92e28b12e
MD5 5fe6edc29b0ddfd97fd78486e06473f3
BLAKE2b-256 8a30db50527384fd577baf893d8a63730424c4a94091db58d0079df69ad4694a

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