hydraveil-gui/gui/v2/actions/config.py

31 lines
1 KiB
Python
Executable file

from core.utils.basic_operations.write_or_read_from_json import read_entire_json, write_json_to_file
import os
def setup_gui_directory(gui_cache_home, gui_config_home, gui_config_file) -> bool:
os.makedirs(gui_cache_home, exist_ok=True)
os.makedirs(gui_config_home, exist_ok=True)
if not os.path.exists(gui_config_file):
default_config = {
"logging": {
"gui_logging_enabled": False,
"log_level": "INFO"
}
}
return write_json_to_file(data=default_config, filepath=gui_config_file)
return True
def load_gui_config(gui_config_file) -> str|None:
"""Pass through to core for better error handling, such as UnicodeDecodeError."""
return read_entire_json(gui_config_file)
def save_gui_config(gui_config_file, config) -> bool:
"""Pass through to core for better error handling"""
return write_json_to_file(data=config, filepath=gui_config_file)
def default_gui_config():
return {"logging": {"gui_logging_enabled": False, "log_level": "INFO"}}