Always touch config file dir if dne

agg_feedz
Tyler Goodlet 2022-11-11 17:39:46 -05:00
parent 79fcbcc281
commit c088963cf2
1 changed files with 6 additions and 3 deletions

View File

@ -197,6 +197,9 @@ def load(
''' '''
path = path or get_conf_path(conf_name) path = path or get_conf_path(conf_name)
if not os.path.isdir(_config_dir):
os.mkdir(_config_dir)
if not os.path.isfile(path): if not os.path.isfile(path):
fn = _conf_fn_w_ext(conf_name) fn = _conf_fn_w_ext(conf_name)
@ -209,9 +212,9 @@ def load(
# if one exists. # if one exists.
if os.path.isfile(template): if os.path.isfile(template):
shutil.copyfile(template, path) shutil.copyfile(template, path)
else: else:
with open(path, 'w'): with open(path, 'r'):
pass # touch pass # touch it
config = toml.load(path, **tomlkws) config = toml.load(path, **tomlkws)
log.debug(f"Read config file {path}") log.debug(f"Read config file {path}")