fxutils
check_and_create_lock_file
Check for an existing lock and handle it appropriately.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lock_file_path |
str
|
The path to the lock file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
get_configuration_file_values
get_configuration_file_values(
file_name: str, sections_options: Dict[str, List[str]]
) -> Dict[str, Dict[str, Optional[str]]]
Reads values from a configuration file for given sections and their options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name |
str
|
The name of the configuration file. |
required |
sections_options |
Dict[str, List[str]]
|
A dictionary where keys are section names and values are lists of options in those sections. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Dict[str, Optional[str]]]
|
Dict[str, Dict[str, Optional[str]]]: A nested dictionary where the
first level keys are section names, and their values are
dictionaries with options as keys and their values as values.
If an option is not found, its value will be |
Examples:
is_process_running
Check if there's a running process with the given PID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pid |
int
|
The process ID to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
is_valid_string
Check if a string is valid for use. Match only alphanumeric characters, underscores, or hyphens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_string |
str
|
The string to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
open_directory
Opens the given file or directory in the system file manager.
remove_lock_file
Remove the lock file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lock_file_path |
str
|
The path to the lock file. |
required |
transform_to_valid_string
Transform a string into a valid format by keeping only alphanumeric characters, underscores, or hyphens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_string |
str
|
The string to transform. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The transformed string with only valid characters. |
update_configuration_file
update_configuration_file(
file_name: str, sections_options_values: dict, temporary: bool = False
) -> None
Updates or creates multiple values in a configuration file based on a nested dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_name |
str
|
The name of the configuration file. |
required |
sections_options_values |
dict
|
A dictionary where keys are section names and values are dictionaries of options and their values to update or create. |
required |
temporary |
bool
|
If |
False
|
Examples: