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, password, 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 library has a rich functionality but furl object is mutable.

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

    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 transformations 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.10.0 (2017-03-14)

  • Added URL.build class method #58

  • Added path_qs attribute #42

0.9.8 (2017-02-16)

  • Do not quote “:” in path

0.9.7 (2017-02-16)

  • Load from pickle without _cache #56

  • Percent-encoded pluses in path variables become spaces #59

0.9.6 (2017-02-15)

  • Revert backward incompatible change (BaseURL)

0.9.5 (2017-02-14)

  • Fix BaseURL rich comparison support

0.9.4 (2017-02-14)

  • Use BaseURL

0.9.3 (2017-02-14)

  • Added BaseURL

0.9.2 (2017-02-08)

  • Remove debug print

0.9.1 (2017-02-07)

  • Do not lose tail chars #45

0.9.0 (2017-02-07)

  • Allow to quote % in non strict mode #21

  • Incorrect parsing of query parameters with %3B (;) inside #34

  • core dumps #41

  • tmpbuf - compiling error #43

  • Added URL.update_path() method

  • Added URL.update_query() method #47

0.8.1 (2016-12-03)

  • Fix broken aiohttp: revert back quote / unquote.

0.8.0 (2016-12-03)

  • Support more verbose error messages in .with_query() #24

  • Don’t percent-encode @ and : in path #32

  • Don’t expose yarl.quote and yarl.unquote, these functions are part of private API

0.7.1 (2016-11-18)

  • Accept not only str but all classes inherited from str also #25

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 construction 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 sequence 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 README, old version used obsolete API

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

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

Uploaded Source

Built Distributions

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

yarl-0.10.0-cp35-cp35m-win_amd64.whl (81.4 kB view details)

Uploaded CPython 3.5mWindows x86-64

yarl-0.10.0-cp35-cp35m-win32.whl (78.4 kB view details)

Uploaded CPython 3.5mWindows x86

yarl-0.10.0-cp35-cp35m-manylinux1_x86_64.whl (165.8 kB view details)

Uploaded CPython 3.5m

yarl-0.10.0-cp35-cp35m-manylinux1_i686.whl (158.2 kB view details)

Uploaded CPython 3.5m

yarl-0.10.0-cp34-cp34m-win_amd64.whl (80.4 kB view details)

Uploaded CPython 3.4mWindows x86-64

yarl-0.10.0-cp34-cp34m-win32.whl (78.4 kB view details)

Uploaded CPython 3.4mWindows x86

yarl-0.10.0-cp34-cp34m-manylinux1_x86_64.whl (168.6 kB view details)

Uploaded CPython 3.4m

yarl-0.10.0-cp34-cp34m-manylinux1_i686.whl (161.5 kB view details)

Uploaded CPython 3.4m

File details

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

File metadata

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

File hashes

Hashes for yarl-0.10.0.tar.gz
Algorithm Hash digest
SHA256 d92947434946bf47e3ee2123f4ea785ea4c7d5ba37c93fd2142470868dc2a01b
MD5 f109f3e2fc5d1a09309afa714591921f
BLAKE2b-256 e4aabc97551a2eb0c25711da61e16940decefdcc41b7bb8897b3c24e1623ef74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 2a83c2941588ac5402fd555870d87060d3b06969a7ec0dc6f1abb286267eebb3
MD5 c94fa9cb7e0e27ba9b4494fd442ab830
BLAKE2b-256 474cc9149b8172941df61cc35356029ecd0abdefb22ae55601bb00a75d5f480e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 a46951f9495372f4ffb34e3ccdebadadfbab9409905f80f20686ea2936f49bdc
MD5 16f15271fbe28af529efda636bbd598b
BLAKE2b-256 053f2d76de13bfb2aa9c476ef94a093031fd4323af31f8d2c264eb03b303ff48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 69903a93487abf971590da771f5b43882ead68e3201bb3a0fb42b7dd74d362ed
MD5 6c496d15a404eb6a1f03db892461f25b
BLAKE2b-256 b578e8685e2bcff2fce30fd9b64e7b369081d070323e84113d99543f3001e275

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 f72e072a8e66545797341f79280de2b0ffa790736d1dafd4d7f3f0b837609dfc
MD5 bdb1075e3d73b980c66fed95ce8e3cb7
BLAKE2b-256 62eed44668ba1901c043cd99cfcc47175ed4913d6f3f2b2ed41b293a54f3fbdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 f118869e37d61e93bc0a5a9669ef57d86da730b8dd75b6f20c8d8e38ca55e48a
MD5 1400fad6a24d5c3b857e5ccfd897f6ba
BLAKE2b-256 61de2cdb04b3fba556c8e071996bcad6526a0f1106cee7044fab6ea8ce5fa5b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 71493dbf4984f4773e90ea17d265ebc112ad2c0fea203c3265e856927c933f9d
MD5 56a896ca99d2f5aa749b5cc1db59ecf9
BLAKE2b-256 48c61bc0e9a1f31a7ea4d66a86a8f6ffa1ee2a165b460fd64e6f1a07c4c6b2f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9cde4e36ac9f485ce52a6d8ea2b89559dd7fc281c3216c83e4291e920fed4faa
MD5 0931b9448ac7b40541ae0228a0716f86
BLAKE2b-256 74c99c932b8c31bc31cf4895d64fedc623b3353a08fb3c560c514a5f8631da49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.10.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 e897e3f2fe76162cdde382b7df29ec222e853522b07649ed33a439bd5538af31
MD5 6af76137794c84ced2103bf9c7cbdb9b
BLAKE2b-256 eb1d2615e0dac685d0b0b9e3aa995b7293c75e4d4e4d6ab9e965635ee90fdb25

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