Exemple #1
0
def read_config(file_path: str,
                template: dict,
                update_file: bool = False,
                update_async: bool = False) -> dict:
    if not os.path.exists(file_path):
        Path(CONFIG_PATH).mkdir(parents=True, exist_ok=True)
        save_config(template, file_path)
    else:
        with open(file_path) as f:
            local_config = yaml.safe_load(f.read())

        if local_config:
            util.deep_update(template, local_config)

        if update_file:
            if update_async:
                Thread(target=save_config,
                       args=(template, file_path),
                       daemon=True).start()
            else:
                save_config(template, file_path)

    return template
Exemple #2
0
 def merge_config(base_config: dict, current_config: dict):
     util.deep_update(base_config, current_config)