Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/__init__.py @ 11:aecb36d4025f
Deactivate the "dict_merge()" function from yconfig
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Wed, 09 Mar 2016 11:32:08 +0100 |
| parents | 58af59d5af40 |
| children | 24ba462b9b4b |
comparison
equal
deleted
inserted
replaced
| 10:58af59d5af40 | 11:aecb36d4025f |
|---|---|
| 17 | 17 |
| 18 | 18 |
| 19 __all__ = [] | 19 __all__ = [] |
| 20 | 20 |
| 21 | 21 |
| 22 # | 22 if 0: |
| 23 # From: https://github.com/jet9/python-yconfig/blob/master/yconfig.py | 23 # |
| 24 # License: BSD License | 24 # From: https://github.com/jet9/python-yconfig/blob/master/yconfig.py |
| 25 # | 25 # License: BSD License |
| 26 def dict_merge(a, b): | 26 # |
| 27 """Recursively merges dict's. not just simple a['key'] = b['key'], if | 27 def dict_merge(a, b): |
| 28 both a and bhave a key who's value is a dict then dict_merge is called | 28 """Recursively merges dict's. not just simple a['key'] = b['key'], if |
| 29 on both values and the result stored in the returned dictionary.""" | 29 both a and bhave a key who's value is a dict then dict_merge is called |
| 30 on both values and the result stored in the returned dictionary.""" | |
| 30 | 31 |
| 31 if not isinstance(b, dict): | 32 if not isinstance(b, dict): |
| 32 return b | 33 return b |
| 33 result = deepcopy(a) | 34 result = deepcopy(a) |
| 34 for k, v in b.iteritems(): | 35 for k, v in b.iteritems(): |
| 35 if k in result and isinstance(result[k], dict): | 36 if k in result and isinstance(result[k], dict): |
| 36 result[k] = dict_merge(result[k], v) | 37 result[k] = dict_merge(result[k], v) |
| 37 else: | 38 else: |
| 38 result[k] = deepcopy(v) | 39 result[k] = deepcopy(v) |
| 39 return result | 40 return result |
| 40 | 41 |
| 41 | 42 |
| 42 def merge(user, default): | 43 def merge(user, default): |
| 43 """A simple (YAML-)tree merge. | 44 """A simple (YAML-)tree merge. |
| 44 | 45 |
