Skip to main content

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

Project description

Latest PyPI version Number of PyPI downloads

This module defines RFC 3986 compliant replacements for the most commonly used functions of the Python Standard Library urlparse module.

>>> from uritools import urisplit, uriunsplit, urijoin, uridefrag
>>> p = urisplit('foo://example.com:8042/over/there?name=ferret#nose')
>>> p
SplitResult(scheme='foo', authority='example.com:8042',
            path='/over/there', query='name=ferret', fragment='nose')
>>> p.scheme
'foo'
>>> p.authority
'example.com:8042'
>>> p.port
8042
>>> p.geturi()
'foo://example.com:8042/over/there?name=ferret#nose'
>>> uriunsplit(['foo', 'example.com:8042', '/over/there', None, None])
'foo://example.com:8042/over/there'
>>> 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 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.

The uritools 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

To install uritools using pip:

pip install uritools

Project Resources

Changelog

v0.2.0 (2014-02-18)

  • Add authority subcomponent attributes.

  • Return DefragResult from uridefrag().

  • Improve urisplit/uriunsplit edge case behavior.

v0.1.0 (2014-02-14)

  • Initial beta release.

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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for uritools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c63fa4275b02a8e474c0e2937eb71d7774e4da53bdf2d840f0df8bc440046086
MD5 f925d26f4fc7ff3f2f8e40465831006b
BLAKE2b-256 35eddd9413342480f59c286ac5d6713470e837b198bf5f1cc20c5c24a5f19535

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