config.py

changeset 4
d72c4844e791
parent 3
4cad934aa9ce
child 21
c36e549a7f12
equal deleted inserted replaced
3:4cad934aa9ce 4:d72c4844e791
5 import yaml 5 import yaml
6 import io 6 import io
7 import os 7 import os
8 import xdg 8 import xdg
9 import string 9 import string
10 import logging
10 from functools import reduce 11 from functools import reduce
11 12
12 # 13 #
13 # Defaults 14 # Defaults
14 # 15 #
110 111
111 return out 112 return out
112 113
113 cfgfile=os.path.join(xdg.XDG_CONFIG_HOME, "borgend", "config.yaml") 114 cfgfile=os.path.join(xdg.XDG_CONFIG_HOME, "borgend", "config.yaml")
114 115
116 logging.info("Reading configuration file %s" % cfgfile)
117
115 if not (os.path.exists(cfgfile) and os.path.isfile(cfgfile)): 118 if not (os.path.exists(cfgfile) and os.path.isfile(cfgfile)):
116 raise SystemExit(f'Configuration file required: {cfgfile}') 119 raise SystemExit(f'Configuration file required: {cfgfile}')
117 120
118 with io.open(cfgfile, 'r') as file: 121 with io.open(cfgfile, 'r') as file:
119 settings=expand_env(yaml.load(file), os.environ); 122 settings=expand_env(yaml.load(file), os.environ);

mercurial