Skip to content

Commit

Permalink
Always touch config file dir if dne
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Nov 11, 2022
1 parent 3aad003 commit 9ca5152
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions piker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def load(
'''
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):
fn = _conf_fn_w_ext(conf_name)

Expand All @@ -209,9 +212,9 @@ def load(
# if one exists.
if os.path.isfile(template):
shutil.copyfile(template, path)
else:
with open(path, 'w'):
pass # touch
else:
with open(path, 'r'):
pass # touch it

config = toml.load(path, **tomlkws)
log.debug(f"Read config file {path}")
Expand Down

0 comments on commit 9ca5152

Please sign in to comment.