Thu, 18 Jan 2018 23:01:16 +0000
basic scheduler structure draft, etc.
# # Borgend configuration loader # import yaml import io import os import xdg import string def expand_env(cfg, env): if isinstance(cfg, dict): out={key: expand_env(val, env) for key, val in cfg.items()} elif isinstance(cfg, list): out=[expand_env(val, env) for val in cfg] elif isinstance(cfg, str): out=string.Template(cfg).substitute(os.environ) else: out=cfg return out cfgfile=os.path.join(xdg.XDG_CONFIG_HOME, "borgend", "config.yaml") if not (os.path.exists(cfgfile) and os.path.isfile(cfgfile)): raise SystemExit(f'Configuration file required: {cfgfile}') with io.open(cfgfile, 'r') as file: settings=expand_env(yaml.load(file), os.environ);