Default to scope with highest precedence instead of user scope,

- Generalizes config scopes a bit more: nothing assumes there is a
  'user' scope (this would break testing sometimes).
This commit is contained in:
Todd Gamblin 2015-12-25 18:42:06 -08:00
parent c65fd3a289
commit bef52570ae
2 changed files with 10 additions and 2 deletions

View file

@ -84,7 +84,7 @@ def get_compiler_config(arch=None):
compilers = find_compilers(*get_path('PATH'))
for compiler in compilers:
config[arch].update(_to_dict(compiler))
spack.config.update_config('compilers', config, 'user')
spack.config.update_config('compilers', config)
# Merge 'all' compilers with arch-specific ones.
merged_config = config.get('all', {})

View file

@ -193,8 +193,16 @@ def clear(self):
def check_scope(scope):
"""Ensure that scope is valid, and return a valid scope if it is None.
This should be used by routines in ``config.py`` to validate
scope name arguments, and to determine a default scope where no
scope is specified.
"""
if scope is None:
return 'user'
# default to the scope with highest precedence.
return config_scopes[-1]
elif scope not in valid_scopes:
raise ValueError("Invalid config scope: '%s'. Must be one of %s."
% (scope, valid_scopes))