speasy.core.url_utils module

speasy.core.url_utils.build_url(base: str, parameters: Dict) str[source]
speasy.core.url_utils.ensure_url_scheme(url: str) str[source]

Adds file:// to url for local files

Parameters:
urlstr

url with or without scheme

Returns
——-
str

url with ‘file:’ scheme added when none was provided else input url

speasy.core.url_utils.host_and_port(url: str) Tuple[str, int][source]

Returns the host and port of an url

Parameters:
urlstr

url with or without scheme

Returns:
Tuple[str, str]

host and port of the url, defaults to 80 if no port or scheme is provided

speasy.core.url_utils.is_local_file(url: str)[source]

Returns true if url correspond to a local path.

Parameters:
urlstr

file url formatted as local path or standard URL format (https://en.wikipedia.org/wiki/URL)

Returns:
bool

True if matches any local path/URL

Examples

>>> from speasy.core.url_utils import is_local_file
>>> is_local_file("/some/path")
True
>>> is_local_file("C:/some/path")
True
>>> is_local_file("file:///some/path")
True
>>> is_local_file("http://some/path")
False
speasy.core.url_utils.quote(*args, **kwargs)[source]