diff options
author | Matthew LeGendre <legendre1@llnl.gov> | 2015-07-07 16:28:51 -0700 |
---|---|---|
committer | Matthew LeGendre <legendre1@llnl.gov> | 2015-10-05 11:36:06 -0700 |
commit | 53d70fff0121a05fb21c02363570f81573bbeffa (patch) | |
tree | 49336f19ccc8fab69f3ba2dec9106d21c6491346 | |
parent | 53cde110b1d25f8fcf89d7c26ef02bb073cb6a29 (diff) | |
download | spack-53d70fff0121a05fb21c02363570f81573bbeffa.tar.gz spack-53d70fff0121a05fb21c02363570f81573bbeffa.tar.bz2 spack-53d70fff0121a05fb21c02363570f81573bbeffa.tar.xz spack-53d70fff0121a05fb21c02363570f81573bbeffa.zip |
Fix type error with YAML config when merging lists from different configs.
-rw-r--r-- | lib/spack/spack/config.py | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index dbe225960a..f3526b19fa 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -98,6 +98,7 @@ from external import yaml from external.yaml.error import MarkedYAMLError import llnl.util.tty as tty from llnl.util.filesystem import mkdirp +import copy _config_sections = {} class _ConfigCategory: @@ -159,21 +160,19 @@ def _merge_dicts(d1, d2): if not d2: return d1 - for key2, val2 in d2.iteritems(): - if not key2 in d1: - d1[key2] = val2 - continue - val1 = d1[key2] - if isinstance(val1, dict) and isinstance(val2, dict): - d1[key2] = _merge_dicts(val1, val2) - continue - if isinstance(val1, list) and isinstance(val2, list): - val1.extend(val2) - seen = set() - d1[key2] = [ x for x in val1 if not (x in seen or seen.add(x)) ] - continue - d1[key2] = val2 - return d1 + if (type(d1) is list) and (type(d2) is list): + d1.extend(d2) + return d1 + + if (type(d1) is dict) and (type(d2) is dict): + for key2, val2 in d2.iteritems(): + if not key2 in d1: + d1[key2] = val2 + else: + d1[key2] = _merge_dicts(d1[key2], val2) + return d1 + + return d2 def get_config(category_name): @@ -225,8 +224,8 @@ def get_compilers_config(arch=None): def get_mirror_config(): - """Get the mirror configuration from config files""" - return get_config('mirrors') + """Get the mirror configuration from config files as a list of name/location tuples""" + return [x.items()[0] for x in get_config('mirrors')] def get_preferred_config(): |