Skip to main content

Yet another URL library

Project description

yarl

https://travis-ci.org/aio-libs/yarl.svg?branch=master https://codecov.io/gh/aio-libs/yarl/branch/master/graph/badge.svg https://badge.fury.io/py/yarl.svg https://readthedocs.org/projects/yarl/badge/?version=latest https://img.shields.io/pypi/pyversions/yarl.svg

Introduction

Url is constructed from str:

>>> from yarl import URL
>>> url = URL('https://www.python.org/~guido?arg=1#frag')
>>> url
URL('https://www.python.org/~guido?arg=1#frag')

All url parts: scheme, user, passsword, host, port, path, query and fragment are accessible by properties:

>>> url.scheme
'https'
>>> url.host
'www.python.org'
>>> url.path
'/~guido'
>>> url.query_string
'arg=1'
>>> url.query
<MultiDictProxy('arg': '1')>
>>> url.fragment
'frag'

All url manipulations produces a new url object:

>>> url.parent / 'downloads/source'
URL('https://www.python.org/downloads/source')

Strings passed to constructor and modification methods are automatically encoded giving canonical representation as result:

>>> url = URL('https://www.python.org/путь')
>>> url
URL('https://www.python.org/%D0%BF%D1%83%D1%82%D1%8C')

Regular properties are percent-decoded, use raw_ versions for getting encoded strings:

>>> url.path
'/путь'

>>> url.raw_path
'/%D0%BF%D1%83%D1%82%D1%8C'

Human readable representation of URL is available as .human_repr():

>>> url.human_repr()
'https://www.python.org/путь'

For full documentation please read https://yarl.readthedocs.org.

Installation

$ pip install yarl

The library is Python 3 only!

Dependencies

YARL requires multidict library.

API documentation

The documentation is located at https://yarl.readthedocs.org

Comparison with other URL libraries

  • furl (https://pypi.python.org/pypi/furl)

    The libray has a rich functionality but furl object is mutable.

    I afraid to pass this object into foreign code: who knows if the code will modifiy my url in a terrible way while I just want to send URL with handy helpers for accessing URL properies.

    furl has other non obvious tricky things but the main objection is mutability.

  • URLObject (https://pypi.python.org/pypi/URLObject)

    URLObject is immutable, that’s pretty good.

    Every URL change generates a new URL object.

    But the library doesn’t any decode/encode transormations leaving end user to cope with these gory details.

Source code

The project is hosted on GitHub

Please file an issue on the bug tracker if you have found a bug or have some suggestion in order to improve the library.

The library uses Travis for Continuous Integration.

Discussion list

aio-libs google group: https://groups.google.com/forum/#!forum/aio-libs

Feel free to post your questions and ideas here.

Authors and License

The yarl package is written by Andrew Svetlov.

It’s Apache 2 licensed and freely available.

CHANGES

0.7.0 (2016-11-07)

  • Accept int as value for .with_query()

0.6.0 (2016-11-07)

  • Explicitly use UTF8 encoding in setup.py #20

  • Properly unquote non-UTF8 strings #19

0.5.3 (2016-11-02)

  • Don’t use namedtuple fields but indexes on URL construction

0.5.2 (2016-11-02)

  • Inline _encode class method

0.5.1 (2016-11-02)

  • Make URL counstruction faster by removing extra classmethod calls

0.5.0 (2016-11-02)

  • Add cython optimization for quoting/unquoting

  • Provide binary wheels

0.4.3 (2016-09-29)

  • Fix typing stubs

0.4.2 (2016-09-29)

  • Expose quote() and unquote() as public API

0.4.1 (2016-09-28)

  • Support empty values in query (‘/path?arg’)

0.4.0 (2016-09-27)

  • Introduce relative() #16

0.3.2 (2016-09-27)

  • Typo fixes #15

0.3.1 (2016-09-26)

  • Support sequience of pairs as with_query() parameter

0.3.0 (2016-09-26)

  • Introduce is_default_port()

0.2.1 (2016-09-26)

0.2.0 (2016-09-18)

  • Avoid doubling slashes when joining paths #13

  • Appending path starting from slash is forbidden #12

0.1.4 (2016-09-09)

  • Add kwargs support for with_query() #10

0.1.3 (2016-09-07)

  • Document with_query(), with_fragment() and origin()

  • Allow None for with_query() and with_fragment()

0.1.2 (2016-09-07)

  • Fix links, tune docs theme.

0.1.1 (2016-09-06)

  • Update REAMDE, old version used obsolete AIP

0.1.0 (2016-09-06)

  • The library was deeply refactored, bytes are gone away but all accepted strings are encoded if needed.

0.0.1 (2016-08-30)

  • The first release.

Project details


Release history Release notifications | RSS feed

This version

0.7.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yarl-0.7.0.tar.gz (117.8 kB view details)

Uploaded Source

Built Distributions

yarl-0.7.0-cp35-cp35m-win_amd64.whl (70.6 kB view details)

Uploaded CPython 3.5m Windows x86-64

yarl-0.7.0-cp35-cp35m-win32.whl (68.1 kB view details)

Uploaded CPython 3.5m Windows x86

yarl-0.7.0-cp35-cp35m-manylinux1_x86_64.whl (130.6 kB view details)

Uploaded CPython 3.5m

yarl-0.7.0-cp35-cp35m-manylinux1_i686.whl (124.8 kB view details)

Uploaded CPython 3.5m

yarl-0.7.0-cp34-cp34m-win_amd64.whl (69.5 kB view details)

Uploaded CPython 3.4m Windows x86-64

yarl-0.7.0-cp34-cp34m-win32.whl (67.9 kB view details)

Uploaded CPython 3.4m Windows x86

yarl-0.7.0-cp34-cp34m-manylinux1_x86_64.whl (132.6 kB view details)

Uploaded CPython 3.4m

yarl-0.7.0-cp34-cp34m-manylinux1_i686.whl (126.4 kB view details)

Uploaded CPython 3.4m

File details

Details for the file yarl-0.7.0.tar.gz.

File metadata

  • Download URL: yarl-0.7.0.tar.gz
  • Upload date:
  • Size: 117.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yarl-0.7.0.tar.gz
Algorithm Hash digest
SHA256 43222e76b17d62e23c2ff62dde7b6d3cd64453be7529876b4967ec5c3e0fa3fd
MD5 d658c903a4666979913a7487c1d06574
BLAKE2b-256 6a09c7213413ea440e489d13aa53c6ffc80b532070d28a0a75cf56691eaf522e

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 f834f0d9f1280be7bc412e96edf5ba73e1dc87df608cdc354582a6dfbe2e4215
MD5 e7dd1c8f9a1c0b0cc8a158ab53ea5ff2
BLAKE2b-256 f1480665d587e97ff021fe38cc799ce0bfce361954d5fa0f3ed093030a272314

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 1d5a7cfb39d153125e66b3e4ab8b078770a3e55449021e4baa8358e34231d14f
MD5 10bde8ca71c6c215bb3181c0aef1281e
BLAKE2b-256 d8c26705fd9dc967550c95963dbad9dd02e7450b64c5194d7838ffd0f20a0c4a

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c8da4388fb12e616a5ca7f77fd79fca6f8d38120d8e9284d41872005a51cf4c2
MD5 6cbcce48b2967ac1e90627d406bcfd16
BLAKE2b-256 083fea0f5c01c231ca264c23668b5faef588a8c733f43f6c0b0b96bd9c49bc0d

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6d38843d39d1ff9de43822912c496ad0f252707d6ef4b58d6a699ac28e1b4ebd
MD5 feda9ed0b78d54d57b7c8cc0492b00a2
BLAKE2b-256 d1e1fcd49c102484e60a935f30385a6b00bbe200c4b6b83a5dc695fdba2c5c20

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp34-cp34m-win_amd64.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 dc08bc2a4785b4ecc52963811f0bcf197ccb2d76a50236da457c2a687f6abaa2
MD5 ca240c2872329de1b311459ce022c367
BLAKE2b-256 3615d74fb03fc5f66ef6cd9836b32182c96bf72c10e28b967e5441e54557212e

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp34-cp34m-win32.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 e57f4afbb2bf0c27255eb6e31e14fe6084c7f4b22b0dbf37275930ad7380e056
MD5 8e9cef8de72d222c13fbefaafa08e883
BLAKE2b-256 5f7d2de87846f19a836f60f5cde8537c7135a5e600f1942eca0722f3e7d89059

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7c3d072ee35071a58299ea6275dff260ea271df58ee6c61c680888eaac39867f
MD5 7d52476329d1ac28836f4c681f9c8c4a
BLAKE2b-256 6668b09ca7a9ef9936d5df89d7fa6ce1f1b0bb5b922c3b8f26af38e7f9330685

See more details on using hashes here.

File details

Details for the file yarl-0.7.0-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for yarl-0.7.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1583fa707b573623451d298c973837ab8d7bf0fb38483d476aa6c5198f195b72
MD5 02fe49eab18b46a3ee6903e107173c99
BLAKE2b-256 5be3f1705124b43e5b4f2162e84c43388727f1f35b600f43305544a1fc54eab1

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