This module provides various non-oneM2M related utility functions.
| Function | build |
Build a URL with basic auth credentials. |
| Function | get |
Get the basic auth credentials from a URL. |
| Function | get |
Get the name of a thread. |
| Function | hash |
Hash a string using SHA256. |
| Function | is |
Test whether a URL is a valid URL and an internal ACME event URL. |
| Function | is |
Test whether a URL is a valid URL, and indicates a coap or coaps scheme. |
| Function | is |
Test whether a URL is a valid URL, and indicates an http or https scheme. |
| Function | is |
Test whether a URL is a valid URL, and indicates an mqtt URL. |
| Function | is |
Check whether a given string is a URL. |
| Function | is |
Test whether a URL is a valid URL, and indicates a WebSocket URL. |
| Function | normalize |
Remove trailing / from a url. |
| Function | open |
Open a file with the default application. |
| Function | rename |
Rename a thread. |
| Function | reverse |
Reverse enumerate a list. |
| Function | runs |
Check whether the current runtime environment is IPython or not. |
| Function | str |
Convert a string value to a boolean. |
| Variable | _urlregex |
Regular expression to test for a valid URL. |
Build a URL with basic auth credentials.
| Parameters | |
url:str | URL to add the basic auth credentials to. |
username:str | Username for the basic auth. |
password:str | Password for the basic auth. |
| Returns | |
str | URL with the basic auth credentials. |
Get the basic auth credentials from a URL.
| Parameters | |
url:str | URL to extract the basic auth credentials from. |
| Returns | |
tuple[ | A tuple with the URL without the basic auth credentials, the username and the password. |
Get the name of a thread.
| Parameters | |
thread:threading.Thread | None | The Thread to get the name from. If none is provided then the current thread is used. |
| Returns | |
str | The name of the thread. |
Hash a string using SHA256.
| Parameters | |
s:str | String to hash. |
salt:str | Salt to add to the string before hashing. |
| Returns | |
str | The SHA256 hash of the string as hex. |
Test whether a URL is a valid URL and an internal ACME event URL.
| Parameters | |
url:str | URL to check. |
| Returns | |
bool | True if the argument is a URL, and is an internal ACME scheme. |
Test whether a URL is a valid URL, and indicates a coap or coaps scheme.
| Parameters | |
url:str | String to check. |
| Returns | |
bool | True if the argument is a URL, and is an coap or coaps scheme. |
Test whether a URL is a valid URL, and indicates an http or https scheme.
| Parameters | |
url:str | String to check. |
| Returns | |
bool | True if the argument is a URL, and is an http or https scheme. |
Test whether a URL is a valid URL, and indicates an mqtt URL.
| Parameters | |
url:str | String to check. |
| Returns | |
bool | True if the argument is a URL, and is an mqtt or mqtts scheme. |
Check whether a given string is a URL.
| Parameters | |
url:str | String to check for URL-ness. |
| Returns | |
bool | Boolean indicating whether the argument is a valid URL. |
Test whether a URL is a valid URL, and indicates a WebSocket URL.
| Parameters | |
url:str | String to check. |
| Returns | |
bool | True if the argument is a URL, and is a ws or wss scheme. |
Remove trailing / from a url.
| Parameters | |
url:str | URL to remove trailing /'s from. |
| Returns | |
str | URL without trailing /'s. |
str | None = None, name: str | None = None, thread: threading.Thread | None = None) -> bool:
¶
Rename a thread.
If name is provided then the thread is renamed to that name. If name is not provided, but prefix is, then the thread is renamed to the prefix + the last 5 digits of its thread ID. If neither name nor prefix is provided, then the thread is renamed to its own ID.
| Parameters | |
prefix:str | None | Used for "prefix + ID" procedure explained above. |
name:str | None | New name for a thread. |
thread:threading.Thread | None | The Thread to rename. If none is provided then the current thread is renamed. |
| Returns | |
bool | Always True. |
Reverse enumerate a list.
| Parameters | |
data:list | List to enumerate. |
| Returns | |
Generator[ | Generator that yields a tuple with the index and the value of the list. |
Check whether the current runtime environment is IPython or not.
This is a hack!
| Returns | |
bool | True if run in IPython, otherwise False. |