Fix type error with YAML config when merging lists from different configs.
This commit is contained in:
		| @@ -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,22 +160,20 @@ def _merge_dicts(d1, d2): | |||||||
|     if not d2: |     if not d2: | ||||||
|         return d1 |         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(): |         for key2, val2 in d2.iteritems(): | ||||||
|             if not key2 in d1: |             if not key2 in d1: | ||||||
|                 d1[key2] = val2 |                 d1[key2] = val2 | ||||||
|             continue |             else: | ||||||
|         val1 = d1[key2] |                 d1[key2] = _merge_dicts(d1[key2], val2) | ||||||
|         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 |         return d1 | ||||||
|  |  | ||||||
|  |     return d2 | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_config(category_name): | def get_config(category_name): | ||||||
|     """Get the confguration tree for the names category.  Strips off the |     """Get the confguration tree for the names category.  Strips off the | ||||||
| @@ -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(): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Matthew LeGendre
					Matthew LeGendre