util
¶
Utility functions for the package.
get_config_path
¶
get_config_path() -> Path
Get the path to the app config file.
Returns:
Type | Description |
---|---|
Path
|
The path to the app config file. |
Source code in src/images_upload_cli/util.py
17 18 19 20 21 22 23 24 |
|
get_env
¶
Get the value of an environment variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variable |
str
|
The name of the environment variable to retrieve. |
required |
Returns:
Type | Description |
---|---|
str
|
The value of the environment variable, if found. |
Raises:
Type | Description |
---|---|
GetEnvError
|
If the environment variable is not found. |
Source code in src/images_upload_cli/util.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
human_size
¶
Convert bytes to human-readable format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num |
float
|
The number of bytes to be converted. |
required |
suffix |
str
|
The suffix to be appended to the converted size. |
'B'
|
Returns:
Type | Description |
---|---|
str
|
The human-readable size with the appropriate unit and suffix. |
Source code in src/images_upload_cli/util.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
notify_send
¶
notify_send(text_to_print: str) -> None
Send desktop notifications via libnotify.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_to_print |
str
|
The text to be displayed in the desktop notification. |
required |
Source code in src/images_upload_cli/util.py
67 68 69 70 71 72 73 74 |
|
log_on_error
¶
log_on_error(response: Response) -> None
Logs an error message based on the HTTP response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response |
Response
|
The HTTP response object. |
required |
Source code in src/images_upload_cli/util.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|