tik_manager4.core.utils
Cross-platform utility functions.
Attributes
Functions
|
Read and apply the qss file to the given widget. |
|
"Copy the source file or folder to the target location. |
|
Delete the file or folder. |
|
Execute a file. |
Get the user home directory. |
|
|
Convert camel case or snake case to nice name. |
|
Import a Python module from an arbitrary file path. |
|
Move the source file or folder to the target location. |
|
Recursively traverse the data and remove the key. |
|
Sanitizes the given text by removing localized characters, replacing spaces |
|
Write protect the file or folder. |
|
Write unprotect the file or folder. |
Module Contents
- apply_stylesheet(file_path, widget)
Read and apply the qss file to the given widget.
- Args:
file_path (str): The file path to the qss file. widget (QtWidgets.QWidget): The widget to apply the stylesheet to.
- Returns:
bool: True if the file exists and applied, False otherwise.
- copy(source, target, force=True, raise_error=False)
“Copy the source file or folder to the target location.
- delete(file_or_folder)
Delete the file or folder.
- execute(file_path, executable=None)
Execute a file.
- Args:
file_path (str): The file path to execute. executable (str, optional): The executable to use. If not
defined the system defined one will be used. Defaults to None. Flags can be passed at the eng of the string. e.g. “path/to/file -flag1 -flag2”.
- get_home_dir()
Get the user home directory.
- get_nice_name(input_str)
Convert camel case or snake case to nice name.
- import_from_path(module_name, file_path, cleanup=True)
Import a Python module from an arbitrary file path.
- Args:
module_name (str): Name to assign to the module. file_path (str or Path): Full path to the Python file. cleanup (bool): Whether to remove the directory from sys.path after import.
Defaults to True. If the directory was already in sys.path, it will not be removed regardless of this setting.
- Returns:
module: The imported module.
- move(source, target, force=True, raise_error=False)
Move the source file or folder to the target location.
If force is True, any existing file or folder at the target location will be removed before the move operation.
- remove_key(data, key)
Recursively traverse the data and remove the key.
- sanitize_text(text, allow_spaces=False)
Sanitizes the given text by removing localized characters, replacing spaces with underscores, and removing or replacing illegal characters based on the pattern.
- write_protect(file_or_folder)
Write protect the file or folder.
- write_unprotect(file_or_folder)
Write unprotect the file or folder.
- CURRENT_PLATFORM
- LOG