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
>>> uri = urisplit('foo://example.com:8042/over/there?name=ferret#nose')
>>> uri
SplitResult(scheme='foo', authority='example.com:8042', path='/over/there',
            query='name=ferret', fragment='nose')
>>> uri.scheme
'foo'
>>> uri.authority
'example.com:8042'
>>> uri.host
'example.com'
>>> uri.port
8042
>>> uri.geturi()
'foo://example.com:8042/over/there?name=ferret#nose'
>>> uriunsplit(uri[:3] + ('name=swallow&type=African', 'beak'))
'foo://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(base='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 urlparse module is not compliant with current Internet standards, does not include Unicode support, and is generally unusable with proprietary URI schemes. As stated in Lib/urlparse.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 handling Unicode, normalizing URI paths, and conveniently composing URIs from their individual components.

Installation

Install uritools using pip:

pip install uritools

Project Resources

Latest PyPI version Number of PyPI downloads

License

Copyright (c) 2014 Thomas Kemmer.

Licensed under the MIT License.

Known Bugs and Limitations

This modules does not handle IPv6 host addresses (yet).

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.5.2.tar.gz (16.1 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for uritools-0.5.2.tar.gz
Algorithm Hash digest
SHA256 c9cc33f6e8d051bcfedb170510f50517628dc9efac85a1c2004ab567202cb36b
MD5 5372d1dc1b4741e17a0546f2011815a7
BLAKE2b-256 06faca903cdfa3c98e77a848895b5fabceb67d634b60444d042f89dc73c549ba

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