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

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.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.5.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.5.0.tar.gz (115.4 kB view details)

Uploaded Source

Built Distributions

yarl-0.5.0-cp35-cp35m-win_amd64.whl (67.5 kB view details)

Uploaded CPython 3.5mWindows x86-64

yarl-0.5.0-cp35-cp35m-win32.whl (65.0 kB view details)

Uploaded CPython 3.5mWindows x86

yarl-0.5.0-cp35-cp35m-manylinux1_x86_64.whl (122.9 kB view details)

Uploaded CPython 3.5m

yarl-0.5.0-cp35-cp35m-manylinux1_i686.whl (117.7 kB view details)

Uploaded CPython 3.5m

yarl-0.5.0-cp34-cp34m-win_amd64.whl (66.4 kB view details)

Uploaded CPython 3.4mWindows x86-64

yarl-0.5.0-cp34-cp34m-win32.whl (65.0 kB view details)

Uploaded CPython 3.4mWindows x86

yarl-0.5.0-cp34-cp34m-manylinux1_x86_64.whl (124.8 kB view details)

Uploaded CPython 3.4m

yarl-0.5.0-cp34-cp34m-manylinux1_i686.whl (119.6 kB view details)

Uploaded CPython 3.4m

File details

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

File metadata

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

File hashes

Hashes for yarl-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b373709a06bd17bac98d6e32e9c19a3474ad966b9036eb7be325176e629cd384
MD5 6ec30105235bc53c15778afa99e78021
BLAKE2b-256 5b0044694fdda47be4275aa04fe2d97e41ffcbc00933e8ed34e3f972a96ac9fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.5.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 aa1d87d95b6f3f66b743cea1b9e093489b55ec4f10745c509e5d905ec4b7608c
MD5 aa4d6173877aa67d5b6d70addd71dbe9
BLAKE2b-256 53d74f498611d17871cac4360c854089e25e947d2cfbae631a1e52fde823fcaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yarl-0.5.0-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yarl-0.5.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 ebd2b3b1da2d4716269643106b81e36dbaf136b407ab9674794370d68b6475da
MD5 dae7ba0a66621b33251f0ef6d2c37a1e
BLAKE2b-256 6ec63e1d6a2da539f81862bee29dcdbebc8b663eb743b1710d77958a472b1309

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.5.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d12197d4b6f354c7b9a8cd24d50af1646d7909cd1afefb31272909d0f59888b9
MD5 8754b61b111e2df2ce3e886f7ccc2738
BLAKE2b-256 bbe01c951841b05a83f56ae3ca353b52fba86add013b8791c45906ee900841ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.5.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6ab08fc1d288afe05218672c7e4c06427ff032c5c985f667f64d838528258e2b
MD5 cd56e22b469fafc3dc2cc66e60a4a68e
BLAKE2b-256 5fab8823edd98c268e15a5b5c43fe971fdb85ca5c457cab3eca806f3a76b4eae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.5.0-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 627036f0ff6da7f38aa7c3fd4f0c84db91620ce16df2befa504e3b2d54692b69
MD5 a0e9408bac80ab53a40c9e10dd1b3726
BLAKE2b-256 717ee810dc225d1114ebaa84b05d8139cd66355020a932ca3f79e672bab6cc1c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yarl-0.5.0-cp34-cp34m-win32.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: CPython 3.4m, Windows x86
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yarl-0.5.0-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 fbd212ca031e48607b4e31b0e8fd60e139db16e1deae3750a9fb6c9012298135
MD5 a6ed18b71fe420ab960e3bdc9f72e43a
BLAKE2b-256 98cb1bca5d553a51fc97cd6d7cedabd1ff8356bca6b40dd185f9ef3d0ddb1411

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.5.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 10af469b8c6c82efdaec5a0dcf87a6314ecaa22c5666d2224616e0547c3afd67
MD5 493e663c3fd3d39d7f7bacd7ec6b5caf
BLAKE2b-256 9825cd68776691f674608f11895f941109b83fb558167a5d3849ec49a79ec0ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yarl-0.5.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ee99d9ed2743748106e573b2d9efb31ec21b56810d3e5ce0a90a6473042c6f39
MD5 8afb1b9ebf11269c580e582c51aa3650
BLAKE2b-256 c71c0f59d04c31f5ae475b5cb9cde89e0d848e0eb0a11375d9ee11923ee78bcf

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