Fix type error with YAML config when merging lists from different configs.
This commit is contained in:
parent
53cde110b1
commit
53d70fff01
1 changed files with 16 additions and 17 deletions
|
@ -98,6 +98,7 @@
|
||||||
from external.yaml.error import MarkedYAMLError
|
from external.yaml.error import MarkedYAMLError
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
from llnl.util.filesystem import mkdirp
|
from llnl.util.filesystem import mkdirp
|
||||||
|
import copy
|
||||||
|
|
||||||
_config_sections = {}
|
_config_sections = {}
|
||||||
class _ConfigCategory:
|
class _ConfigCategory:
|
||||||
|
@ -159,21 +160,19 @@ def _merge_dicts(d1, d2):
|
||||||
if not d2:
|
if not d2:
|
||||||
return d1
|
return d1
|
||||||
|
|
||||||
for key2, val2 in d2.iteritems():
|
if (type(d1) is list) and (type(d2) is list):
|
||||||
if not key2 in d1:
|
d1.extend(d2)
|
||||||
d1[key2] = val2
|
return d1
|
||||||
continue
|
|
||||||
val1 = d1[key2]
|
if (type(d1) is dict) and (type(d2) is dict):
|
||||||
if isinstance(val1, dict) and isinstance(val2, dict):
|
for key2, val2 in d2.iteritems():
|
||||||
d1[key2] = _merge_dicts(val1, val2)
|
if not key2 in d1:
|
||||||
continue
|
d1[key2] = val2
|
||||||
if isinstance(val1, list) and isinstance(val2, list):
|
else:
|
||||||
val1.extend(val2)
|
d1[key2] = _merge_dicts(d1[key2], val2)
|
||||||
seen = set()
|
return d1
|
||||||
d1[key2] = [ x for x in val1 if not (x in seen or seen.add(x)) ]
|
|
||||||
continue
|
return d2
|
||||||
d1[key2] = val2
|
|
||||||
return d1
|
|
||||||
|
|
||||||
|
|
||||||
def get_config(category_name):
|
def get_config(category_name):
|
||||||
|
@ -225,8 +224,8 @@ def get_compilers_config(arch=None):
|
||||||
|
|
||||||
|
|
||||||
def get_mirror_config():
|
def get_mirror_config():
|
||||||
"""Get the mirror configuration from config files"""
|
"""Get the mirror configuration from config files as a list of name/location tuples"""
|
||||||
return get_config('mirrors')
|
return [x.items()[0] for x in get_config('mirrors')]
|
||||||
|
|
||||||
|
|
||||||
def get_preferred_config():
|
def get_preferred_config():
|
||||||
|
|
Loading…
Reference in a new issue