Skip to main content

Fast quoting and unquoting of urls.

Project description

Build Status

Urlquote

Fast percent encoding / decoding for python.

This library is not intended to be a replacement for urllib. urllib is part of the Python standard library and should be your go-to choice to quote and unquote URLs. However, should quoting or unquoting of URLs be known to be a performance bottleneck and you are fine with the encoding described below, then by all means have fun using this library.

Usage

from urlquote import quote

quoted = quote('/El Niño/')
assert(quoted == '/El%20Ni%C3%B1o/'.encode('utf-8'))

Compatibility

Since this library uses a cffi interface it should work fine with any version of Python. For Linux the wheel has to be build against a version of libc older or equal to the version of libc on the platform the wheel will be used on.

Installation

pip install urlquote

quote operates on UTF-8-encoded bytes. If passed a string, it will encode it into UTF-8 first. It will always return UTF-8-encoded bytes. unquote behaves the same way.

Encoding

The following encodings are offered. DEFAULT_QUOTING is used in case the quoting parameter is not specified.

Name Additional encoded characters
SIMPLE_QUOTING
DEFAULT_QUOTING space, <,>,`,?,{,}
QUERY_QUOTING space, ",#,<,>
PATH_SEGMENT_QUOTING space, ",#,<,>,`,?,%,/
USERINFO_QUOTING space, ",#,<,>,`,?,{,},/,:,;,=,@,\,[,],^,|
PYTHON_3_7_QUOTING space, ",#,<,>,`,?,{,},$,%,&,\,(,),,,=,;,:,!,@,[,],^,|,+,*

Non printable and non standard ASCII characters are always quoted. The PYTHON_3_7_QUOTING is going to work the same way in every Python version the name is only refering to the urllib default encoding used in Python 3.7.

Development

This library is a thin wrapper around the Rust crate percent-encoding. It exposes part of its functionality to python via a C interface using milksnake.

To build it you need to install Rust and Cargo. Than you can proceed to build the wheel with:

python setup.py build sdist bdist_wheel

To execute the Python tests use:

pip install -e .
pytest test.py

There are also some Rust-only unit tests. To execute them change into the rust subdirectory and call.

cargo test

With the nightly toolchain installed you may also call the Rust-only benchmarks using:

cargo +nightly bench

Links

Support

This tool is provided as is under an MIT license without any warranty or SLA. You are free to use it as part for any purpose, but the responsibility for operating it resides with you. We appreciate your feedback though. Contributions on GitHub are welcome.

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

urlquote-1.1.4.tar.gz (23.1 kB view details)

Uploaded Source

Built Distributions

urlquote-1.1.4-py2.py3-none-win_amd64.whl (72.7 kB view details)

Uploaded Python 2 Python 3 Windows x86-64

urlquote-1.1.4-py2.py3-none-manylinux2010_x86_64.whl (611.5 kB view details)

Uploaded Python 2 Python 3 manylinux: glibc 2.12+ x86-64

urlquote-1.1.4-py2.py3-none-manylinux1_x86_64.whl (611.5 kB view details)

Uploaded Python 2 Python 3

urlquote-1.1.4-py2.py3-none-macosx_10_13_x86_64.whl (95.6 kB view details)

Uploaded Python 2 Python 3 macOS 10.13+ x86-64

File details

Details for the file urlquote-1.1.4.tar.gz.

File metadata

  • Download URL: urlquote-1.1.4.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for urlquote-1.1.4.tar.gz
Algorithm Hash digest
SHA256 5f501c939813330151620c06e78038a008af2e8404c41c0b42b30c44471c5427
MD5 b1d4b8c94e7c9aedc91d2cd3ae04943d
BLAKE2b-256 20b2569730b21695ef9a61ac4c48830bc346958d79ff3fd764a239d498789ea7

See more details on using hashes here.

File details

Details for the file urlquote-1.1.4-py2.py3-none-win_amd64.whl.

File metadata

  • Download URL: urlquote-1.1.4-py2.py3-none-win_amd64.whl
  • Upload date:
  • Size: 72.7 kB
  • Tags: Python 2, Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.0

File hashes

Hashes for urlquote-1.1.4-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c59d95524038eaf228c8154293d7e338ffe0bab8deced19d1bc6fb17b07f2a74
MD5 9611301e5ccb8af8c5c7e53a0a88ea5e
BLAKE2b-256 b67f55c1d61c6fd90240b2407aca9e0ddf4abee741f2405d627c2fb1d24db7a5

See more details on using hashes here.

File details

Details for the file urlquote-1.1.4-py2.py3-none-manylinux2010_x86_64.whl.

File metadata

  • Download URL: urlquote-1.1.4-py2.py3-none-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 611.5 kB
  • Tags: Python 2, Python 3, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.12

File hashes

Hashes for urlquote-1.1.4-py2.py3-none-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4f2f35e1eb29b4217d94774166888e3c8c3ddb48d249db073f0e483db3232b3d
MD5 349bd68a538aff60881083ac80b1dd71
BLAKE2b-256 48ff4196e6f744425eb7b9faddc5b66ea9ff30dc9da43edf587dff66ede4145a

See more details on using hashes here.

File details

Details for the file urlquote-1.1.4-py2.py3-none-manylinux1_x86_64.whl.

File metadata

  • Download URL: urlquote-1.1.4-py2.py3-none-manylinux1_x86_64.whl
  • Upload date:
  • Size: 611.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.12

File hashes

Hashes for urlquote-1.1.4-py2.py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4a5e5b2ea480a752d4b85c820e15b22996cae4790fde69ba595d22725e0befea
MD5 2c454c2111804b8cd6901851b867d0f7
BLAKE2b-256 3e6acd4fb36325ddcfbb161203183a83902263f13c9b05987c005824489904ef

See more details on using hashes here.

File details

Details for the file urlquote-1.1.4-py2.py3-none-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: urlquote-1.1.4-py2.py3-none-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 95.6 kB
  • Tags: Python 2, Python 3, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for urlquote-1.1.4-py2.py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e3c2e39f997d4d97faf17daac8776a6aacc52fcff3c20af31eb6a80ea9c5cdd7
MD5 0a8ebd0a0187f6978a17538b92c2c335
BLAKE2b-256 d47a411f2212243973d1e4d2c8ad6373f806de16d0df509d93bccdc96649c3ce

See more details on using hashes here.

Supported by

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