Skip to content

Commit

Permalink
always use default cfg when no valid path was selected #19
Browse files Browse the repository at this point in the history
  • Loading branch information
stolarczyk committed Oct 9, 2019
1 parent 2323484 commit 553d07f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions yacman/yacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ def select_config(config_filepath=None,
if config_filepath:
if not check_exist or os.path.isfile(config_filepath):
return config_filepath
_LOGGER.error("Config file path isn't a file: {}".
format(config_filepath))
_LOGGER.error("Config file path isn't a file: {}".format(config_filepath))
result = on_missing(config_filepath)
if isinstance(result, Exception):
raise result
Expand All @@ -354,15 +353,13 @@ def select_config(config_filepath=None,
cfg_env_var, cfg_file = get_first_env_var(config_env_vars) or ["", ""]

if not check_exist or os.path.isfile(cfg_file):
_LOGGER.debug("Found config file in {}: {}".
format(cfg_env_var, cfg_file))
_LOGGER.debug("Found config file in {}: {}".format(cfg_env_var, cfg_file))
selected_filepath = cfg_file
if selected_filepath is None and cfg_file and strict_env:
raise FileNotFoundError("Environment variable ({}) does not point to any existing file: {}".
format(", ".join(config_env_vars), cfg_file))
else:
if selected_filepath is None:
# Third priority: default filepath
_LOGGER.info("Using default config. No config found in env "
"var: {}".format(str(config_env_vars)))
selected_filepath = default_config_filepath
_LOGGER.info("Using default config. No config found in env var: {}".format(str(config_env_vars)))
return default_config_filepath
return selected_filepath

0 comments on commit 553d07f

Please sign in to comment.