__init__.py 735 B

1234567891011121314151617181920212223
  1. from copy import deepcopy
  2. from .alfred import AlfredParser
  3. from .dashing import DashingClient
  4. from .graphite import GraphitePush
  5. __all__ = [ 'AlfredParser', 'DashingClient', 'GraphitePush', 'dict_merge' ]
  6. def dict_merge(a, b):
  7. '''recursively merges dict's. not just simple a['key'] = b['key'], if
  8. both a and bhave a key who's value is a dict then dict_merge is called
  9. on both values and the result stored in the returned dictionary.'''
  10. if not isinstance(b, dict):
  11. return b
  12. result = deepcopy(a)
  13. for k, v in b.iteritems():
  14. if k in result and isinstance(result[k], dict):
  15. result[k] = dict_merge(result[k], v)
  16. else:
  17. result[k] = deepcopy(v)
  18. return result