12345678910111213141516171819202122 |
- from copy import deepcopy
- from .alfred import AlfredParser
- from .graphite import GraphitePush
- __all__ = [ 'AlfredParser', 'GraphitePush', 'dict_merge' ]
- def dict_merge(a, b):
- '''recursively merges dict's. not just simple a['key'] = b['key'], if
- both a and bhave a key who's value is a dict then dict_merge is called
- on both values and the result stored in the returned dictionary.'''
- if not isinstance(b, dict):
- return b
- result = deepcopy(a)
- for k, v in b.iteritems():
- if k in result and isinstance(result[k], dict):
- result[k] = dict_merge(result[k], v)
- else:
- result[k] = deepcopy(v)
- return result
|