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
SplitResult(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')

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 and urllib.parse, 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, 2015 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-1.0.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

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

uritools-1.0.0-py2.py3-none-any.whl (14.0 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for uritools-1.0.0.tar.gz
Algorithm Hash digest
SHA256 62e24782e1e69404f8909f2e99e0376538bfc7b57038a0b6b2b20590d6f29100
MD5 f5a98618926f4140859cfa50a02006a6
BLAKE2b-256 7afd980d0396218daaea6ae0247bf18fb5b1d5275c75dbe0dd42c8ee714efc12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uritools-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6b8dfab38a5da79516cd66215ebac7d2e41dbc5c6c379d4fb7e1ba01f3ce09ae
MD5 8468341d5c1b3b139ada574c36b737ec
BLAKE2b-256 62c1723621126fc2b57d60bd282fefa52a8a20b8575f24b529ee825ab458deef

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