This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 4.5.

URL Utilities - kombu.utils.url

URL Utilities.

kombu.utils.url.as_url(scheme, host=None, port=None, user=None, password=None, path=None, query=None, sanitize=False, mask='**')[source]

Generate URL from component parts.

kombu.utils.url.maybe_sanitize_url(url, mask='**')[source]

Sanitize url, or do nothing if url undefined.

kombu.utils.url.parse_url(url)[source]

Parse URL into mapping of components.

kombu.utils.url.safequote(string, *, safe='', encoding=None, errors=None)

quote(‘abc def’) -> ‘abc%20def’

Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted.

RFC 3986 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters.

reserved = “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” |

“$” | “,” | “~”

Each of these characters is reserved in some component of a URL, but not necessarily in all of them.

Python 3.7 updates from using RFC 2396 to RFC 3986 to quote URL strings. Now, “~” is included in the set of reserved characters.

By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode ‘/’. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters.

string and safe may be either str or bytes objects. encoding and errors must not be specified if string is a bytes object.

The optional encoding and errors parameters specify how to deal with non-ASCII characters, as accepted by the str.encode method. By default, encoding=’utf-8’ (characters are encoded with UTF-8), and errors=’strict’ (unsupported characters raise a UnicodeEncodeError).

kombu.utils.url.sanitize_url(url, mask='**')[source]

Return copy of URL with password removed.

kombu.utils.url.url_to_parts(url)[source]

Parse URL into urlparts tuple of components.

class kombu.utils.url.urlparts(scheme, hostname, port, username, password, path, query)
property hostname

Alias for field number 1

property password

Alias for field number 4

property path

Alias for field number 5

property port

Alias for field number 2

property query

Alias for field number 6

property scheme

Alias for field number 0

property username

Alias for field number 3