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 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.9.0 (2017-02-07)

  • 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 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.9.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.9.0.tar.gz (124.0 kB view details)

Uploaded Source

Built Distributions

yarl-0.9.0-cp35-cp35m-win_amd64.whl (78.5 kB view details)

Uploaded CPython 3.5m Windows x86-64

yarl-0.9.0-cp35-cp35m-win32.whl (75.6 kB view details)

Uploaded CPython 3.5m Windows x86

yarl-0.9.0-cp35-cp35m-manylinux1_x86_64.whl (156.4 kB view details)

Uploaded CPython 3.5m

yarl-0.9.0-cp35-cp35m-manylinux1_i686.whl (150.0 kB view details)

Uploaded CPython 3.5m

yarl-0.9.0-cp34-cp34m-win_amd64.whl (77.5 kB view details)

Uploaded CPython 3.4m Windows x86-64

yarl-0.9.0-cp34-cp34m-win32.whl (75.7 kB view details)

Uploaded CPython 3.4m Windows x86

yarl-0.9.0-cp34-cp34m-manylinux1_x86_64.whl (159.0 kB view details)

Uploaded CPython 3.4m

yarl-0.9.0-cp34-cp34m-manylinux1_i686.whl (152.5 kB view details)

Uploaded CPython 3.4m

File details

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

File metadata

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

File hashes

Hashes for yarl-0.9.0.tar.gz
Algorithm Hash digest
SHA256 f58c3d854ce17db3d7fb28fe365fb3b3e667c5504f8a7f1be0bc9cd2f72dd614
MD5 beb97ec6c8ffdc018ac4991f26ba75a6
BLAKE2b-256 61aa4e22e8108c4ef5d83c2aaa53726d7c006eaafaa0a29b93c98ae93ee6cf8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 c8b7262241ed5f4b9a232dd6a40f1691d30e0f2e876361889d31cc1c73c8841a
MD5 756127279c2406b3a32bfc79412319f3
BLAKE2b-256 1ff7f18500f8cb8f8bfc0ebb5026a98fbe6f6cb8d391ea327057d0b500173dba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 79336a0a86e037101459687c5e98016b908a5c7e10b6b0612628b1281df2e2d1
MD5 ea4ec6e408352c2b25a0782c3a636f57
BLAKE2b-256 dc8a2dde6b8463f982a23780c69c64f3b55a2e3e4b579cdc3acd92f6e70a20bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8db9cd45c5f4989462dd9367a8ae9ec8441efa7b221bcd4d90769a89c1764fc4
MD5 6e5d6cea749fc85c7ea4627dd1abbff2
BLAKE2b-256 c0aef05e656e325250d1602b62a88bd7de784473bdd28f113fe70aec51031e1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 53ff62691be9d71c27b4c7d9b1dd397628417090c1ff6f2ec397ad221f5d28bc
MD5 d27fc02770dcf2e5e603c26ae94df0ee
BLAKE2b-256 8551d9831134e07706270128fd65e8d1b3a3716d62d49f97aaf9de98d9806a76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 10e5a493083d12e8f608b02fc13b506b5a9444ef35c49a09b4a1ab3cab90c856
MD5 6f08a605a061fdb18b7779b1a58b7e87
BLAKE2b-256 b8291e6280b23268ec96ea9beb14a8cc924344e567ae141e454937ea12aee34b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 dc8b94cdd4802acfb0c7c43eb836c1b91be13e7bdc0dd34f6c6f692890a55994
MD5 8f0c61d603012d6d299a4441a65a7cad
BLAKE2b-256 053755cafacfed6d8095b651b51e89552aa83de6c60452488e1646bbe8dc39b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 212f0e895af58105cbacde52cba0c8a232ec002d1f57b429a20a98e37eb75a84
MD5 6bd1fc25ea9555ac9eeabde66fe507bd
BLAKE2b-256 aa6bc9035c4eb6463f20d6cccdf4a8bd1c6239f2e3c6ba779bfa2eefcbacfd3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.9.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4abfb17fe601598645a6c92482da7faa34b5952b4b1c6a99cd6dd5a996a77632
MD5 6264d83402f7c57a87a4eab8e2a0b3f4
BLAKE2b-256 09a7fb762d9f31876bf1dc0f08ca5e3b30c22b0eb494d8096c0a858bbdcd26a3

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