Utils Module
add_single_quotes_to_list_elements(lst)
Add single quotes to each element in a list or tuple.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lst
|
List | tuple
|
List or tuple of elements to be quoted. |
required |
Returns:
List: List of elements with single quotes added.
Source code in devices\raspberry_pi_5\src\utils\__init__.py
66 67 68 69 70 71 72 73 74 75 |
|
get_local_ip()
Get the local IP address of the machine.
Returns:
Name | Type | Description |
---|---|---|
str |
str | None | Any
|
Local IP address as a string. |
Source code in devices\raspberry_pi_5\src\utils\__init__.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
is_instance(obj, class_or_tuple)
Check if the object is an instance of the specified class or tuple of classes,
unwrapping proxy objects if necessary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
object
|
The object to check. |
required |
class_or_tuple
|
type | UnionType | tuple[Any, ...]
|
The class or tuple of classes to check against. |
required |
Raises:
TypeError: If the object is not an instance of the specified class or tuple of classes.
Source code in devices\raspberry_pi_5\src\utils\__init__.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
is_subclass(cls, class_or_tuple)
Check if the class is a subclass of the specified class or tuple of classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls
|
type
|
The class to check. |
required |
class_or_tuple
|
type | UnionType | tuple[Any, ...]
|
The class or tuple of classes to check against. |
required |
Raises:
TypeError: If the class is not a subclass of the specified class or tuple of classes.
Source code in devices\raspberry_pi_5\src\utils\__init__.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
map_string_to_enum(string, enum_class)
Map a string to an enum class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string
|
str
|
The string to map. |
required |
enum_class
|
type[Enum]
|
The enum class to map the string to. |
required |
Returns:
Any: The corresponding enum value.
Raises:
ValueError: If the string does not match any enum value.
Source code in devices\raspberry_pi_5\src\utils\__init__.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
match_any(regex_list, string)
Match any regex pattern in a List.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
regex_list
|
List[Pattern]
|
List of compiled regex patterns. |
required |
string
|
str
|
String to match against the regex patterns. |
required |
Returns:
bool: True if any regex matches the string, False otherwise.
Source code in devices\raspberry_pi_5\src\utils\__init__.py
53 54 55 56 57 58 59 60 61 62 63 |
|
decorators
ignore_sigint(func)
Decorator to ignore keyboard interrupts (SIGINT) in a function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
function
|
The function to decorate. |
required |
Returns:
Name | Type | Description |
---|---|---|
function |
The decorated function. |
Source code in devices\raspberry_pi_5\src\utils\decorators.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|