Properly default to user_data/config.json if it exists

This commit is contained in:
Matthias
2020-02-14 20:04:05 +01:00
parent be4a9b5f4b
commit 5efbdd25a7
4 changed files with 66 additions and 25 deletions

View File

@@ -111,10 +111,14 @@ class Arguments:
conf_required = ('command' in parsed_arg and parsed_arg.command in NO_CONF_REQURIED)
if 'user_data_dir' in parsed_arg and parsed_arg.user_data_dir is not None:
user_dir = parsed_arg.user_data_dir
else:
# Default case
user_dir = 'user_data'
# Try loading from "user_data/config.json"
cfgfile = Path(parsed_arg.user_data_dir) / DEFAULT_CONFIG
if cfgfile.is_file() or not conf_required:
parsed_arg.config = [str(cfgfile)]
cfgfile = Path(user_dir) / DEFAULT_CONFIG
if cfgfile.is_file():
parsed_arg.config = [str(cfgfile)]
else:
# Else use "config.json".
cfgfile = Path.cwd() / DEFAULT_CONFIG