Skip to main content

`imurl` is an immutable URL library, written in modern Python.

Project description

Code style: black Linter: pylint Checked with mypy

imurl is an immutable URL library, written in modern Python.

imurl is inspired by both purl and Python's pathlib and datetime modules. It aims to provide a simple, immutable data structure to represent URL structures, with support for a wide range of URL/URI schemes.

Examples

Here are some quick examples for imurl. There are more in the documentation.

URLs can be created from URL strings, and have the attributes you'd expect:

>>> from imurl import URL
>>> u = URL("https://example.com")
>>> u
imurl.URL('https://example.com')
>>> u.host
'example.com'
>>> u.scheme
'https'

URLs are immutable, but components can be replaced similarly to datetime/pathlib objects:

>>> u.replace(path="/some/path")
imurl.URL('https://example.com/some/path')
>>> u.path  # This is still `None` - we haven't modified `u`.
>>> u.replace(path="/some/path").path_as_posix
PurePosixPath('/some/path')

URLs can also be built from components, and query/path parameters can be set/get/deleted:

>>> u = URL(scheme="https", host="google.com", path="/search")
imurl.URL('https://google.com/search')
>>> u2 = u.set_query("q", "a+search+term")
>>> u2
imurl.URL('https://google.com/search?q=a+search+term')
>>> u2.delete_query("q")
imurl.URL('https://google.com/search')

Installation

imurl can be installed with pip, and has been tested on Python 3.8. imurl is still alpha software, and should be considered unstable:

pip install imurl

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

imurl-0.1.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file imurl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: imurl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for imurl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 daeb9196e86ffac570ee4439020652c039433f3f393f200766036e0c1f1eca55
MD5 25538eb089fe30f1b6895c9c296cec9f
BLAKE2b-256 3e2086021e376c5cfc3c0fcb8f76aa1d8932f7438eeeefacba4bd3fecf6ab65d

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