Exscript.util.url module

Working with URLs (as used in URL formatted hostnames).

class Exscript.util.url.Url[source]

Bases: future.types.newobject.newobject

Represents a URL.

__init__()[source]

x.__init__(…) initializes x; see help(type(x)) for signature

static from_string(url, default_protocol=u'telnet')[source]

Parses the given URL and returns an URL object. There are some differences to Python’s built-in URL parser:

  • It is less strict, many more inputs are accepted. This is necessary to allow for passing a simple hostname as a URL.
  • You may specify a default protocol that is used when the http:// portion is missing.
  • The port number defaults to the well-known port of the given protocol.
  • The query variables are parsed into a dictionary (Url.vars).
Parameters:
  • url (str) – A URL.
  • default_protocol (string) – A protocol name.
Return type:

Url

Returns:

The Url object contructed from the given URL.

to_string()[source]

Returns the URL, including all attributes, as a string.

Return type:str
Returns:A URL.