ngsildclient.utils.url#
This module contains a few helper functions to deal with URLs.
Module Attributes
Simple regex pattern that matches on strings starting with URL scheme (regex.Pattern). |
Functions
|
URLEncode an URL. |
|
Check if the given string represents an URL. |
|
URLDecode an URL. |
- ngsildclient.utils.url.URL_PATTERN = re.compile('^http[s]{0,1}://')#
Simple regex pattern that matches on strings starting with URL scheme (regex.Pattern).
- ngsildclient.utils.url.escape(value)[source]#
URLEncode an URL.
- Parameters
value (str) – String representation of the URL
- Returns
The encoded URL as a string
- Return type
str
Example
>>> from ngsildclient.utils import url >>> print(url.escape("https://example.com?query=dummy&limit=5")) https%3A//example.com%3Fquery%3Ddummy%26limit%3D5
See also
- ngsildclient.utils.url.isurl(value)[source]#
Check if the given string represents an URL.
Just test whether it starts with “http://” or “https://”
- Parameters
value (str) – The given string to be checked
- Returns
True if the string looks like an URL
- Return type
bool
Example
>>> from ngsildclient.utils import url >>> print(url.isurl("https://example.com?query=dummy&limit=5")) True
- ngsildclient.utils.url.unescape(value)[source]#
URLDecode an URL.
- Parameters
value (str) – String representation of the encoded URL
- Returns
The encoded URL as a string
- Return type
str
Example
>>> from ngsildclient.utils import url >>> print(url.escape("https%3A//example.com%3Fquery%3Ddummy%26limit%3D5")) https://example.com?query=dummy&limit=5
See also