|
hlcc 2.0.0-beta2+pre1
|
Functions | |
| def | find_file (filepath, root_directories=["CFGPATH"], resource_directories=[], exception=False, log_level=logging.INFO) |
| Verifies that the given input file path exist in one of the root directories. | |
| def | resolve_path (path) |
| Resolve the given path. | |
| def | configure_logger (str logger_name, log_level=logging.INFO) |
| Configure logging with predefined formatting and set loglevel. | |
| def utils.file_helper.configure_logger | ( | str | logger_name, |
log_level = logging.INFO |
|||
| ) |
Configure logging with predefined formatting and set loglevel.
| logger_name | logger name |
| level | log level |
| def utils.file_helper.find_file | ( | filepath, | |
root_directories = ["CFGPATH"], |
|||
resource_directories = [], |
|||
exception = False, |
|||
log_level = logging.INFO |
|||
| ) |
Verifies that the given input file path exist in one of the root directories.
| filepath | The file to search (as a relative path) type of filepath: str |
| root_directories | A list of environment variables defining search paths (: separated) to search (default: ["CFGPATH"]) type of root_directories: list or str |
| resource_directories | A list of resource directories to search for inside the |
| root_directories | []). The following are examples of common resource directories that may be used ["config", "audio", "image", "model", "dictionary", "data"]. type of resource_directories: list of str |
| exception | If True it throws an exception if file not not found. If False (default) it returns an empty string if file not found type of exception: bool |
| Exception | if file was not found (and param exception = True). |
Root search paths are loaded from the environment variables in root_directories and the elements of the search path are iterated.
For each path, the file is currently searched iterating for each res_dir in the resource_directories but also for resource/res_dir
The search stops at the first full match and the result is returned.
If the search fails, an empty string is returned or an exception is thrown depending on the value of the exception parameter.
| def utils.file_helper.resolve_path | ( | path | ) |
Resolve the given path.