Always prefer a config template if found
parent
7f246697b4
commit
d3bafb0063
|
@ -228,6 +228,7 @@ def load(
|
||||||
[str | bytes,],
|
[str | bytes,],
|
||||||
MutableMapping,
|
MutableMapping,
|
||||||
] = tomllib.loads,
|
] = tomllib.loads,
|
||||||
|
|
||||||
touch_if_dne: bool = False,
|
touch_if_dne: bool = False,
|
||||||
|
|
||||||
**tomlkws,
|
**tomlkws,
|
||||||
|
@ -249,18 +250,19 @@ def load(
|
||||||
exist_ok=True,
|
exist_ok=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not path.is_file():
|
if (
|
||||||
if path is None:
|
not path.is_file()
|
||||||
fn: str = _conf_fn_w_ext(conf_name)
|
and touch_if_dne
|
||||||
|
):
|
||||||
|
fn: str = _conf_fn_w_ext(conf_name)
|
||||||
|
|
||||||
# try to copy in a template config to the user's directory if
|
# try to copy in a template config to the user's directory if
|
||||||
# one exists.
|
# one exists.
|
||||||
template: Path = repodir() / 'config' / fn
|
template: Path = repodir() / 'config' / fn
|
||||||
if template.is_file():
|
if template.is_file():
|
||||||
shutil.copyfile(template, path)
|
shutil.copyfile(template, path)
|
||||||
|
|
||||||
# touch an empty file
|
else: # just touch an empty file with same name
|
||||||
elif touch_if_dne:
|
|
||||||
with path.open(mode='x'):
|
with path.open(mode='x'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue