Powered by Tachyonic Project Luxon Framework v0.0.0

Luxon Framework for rapid application development. (luxon)

Version

URI

URI Decoder

luxon.utils.uri.decode(encoded_uri)[source]

Decodes percent-encoded characters in a URI or query string.

Parameters:encoded_uri (str) – An encoded URI (full or partial).
Returns:A decoded URL. If the URL contains escaped non-ASCII characters, UTF-8 is assumed per RFC 3986.

URL Cleaner

luxon.utils.uri.clean_uri(uri)[source]

Clean URL.

Replaces two or more / with one in path.

A generic URI is of the form:
scheme://user:password@host:port/path]?query#fragment
Parameters:uri (string) – URL to parse.

Returns: Formatted uri str.

Host from URI

luxon.utils.uri.host_from_uri(uri)[source]

Return only scheme + host + port from uri.

A generic URI is of the form:
scheme://user:password@host:port/path]?query#fragment
Parameters:uri (str) – Standard URL as per RFC3986.
Returns
Value for scheme + host + port as str.

Parse Host

luxon.utils.uri.parse_host(host, default_port=None)[source]

Parse a canonical ‘host:port’ string into parts.

Parse a host string (which may or may not contain a port) into parts, taking into account that the string may contain either a domain name or an IP address. In the latter case, both IPv4 and IPv6 addresses are supported.

Parameters:
  • host (str) – Host string to parse, optionally containing a port number.
  • default_port (int) – Port number to return when the host string does not contain one (default ‘None’).
Returns:

A parsed (host, port) tuple from the given host string, with the port converted to an int. If the host string does not specify a port, default_port is used instead.

Return type:

tuple