You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
import osimport shutil
import appdirs as _appdirsimport toml
def ensure_directory_exists(path): os.makedirs(path, exist_ok=True) return path
appdirs = _appdirs.AppDirs("openwrt_backup")
CONFIG_DIR = ensure_directory_exists(appdirs.user_config_dir)CACHE_DIR = ensure_directory_exists(appdirs.user_cache_dir)CONFIG_FILE_PATH = os.path.join(CONFIG_DIR, "config.toml")PACKAGE_ROOT = os.path.dirname(os.path.abspath(__file__))
if not os.path.exists(CONFIG_FILE_PATH): shutil.copy(os.path.join(PACKAGE_ROOT, "config.toml"), CONFIG_FILE_PATH)
with open(CONFIG_FILE_PATH, "r") as config_file: CONFIG_DATA = toml.load(config_file)
|