Total Complexity | 4 |
Total Lines | 24 |
Duplicated Lines | 0 % |
1 | # Licensed to the StackStorm, Inc ('StackStorm') under one or more |
||
22 | ] |
||
23 | |||
24 | |||
25 | def merge_dicts(d1, d2): |
||
26 | """ |
||
27 | Merge values from d2 into d1 ignoring empty / None values. |
||
28 | |||
29 | :type d1: ``dict`` |
||
30 | :type d2: ``dict`` |
||
31 | |||
32 | :rtype: ``dict`` |
||
33 | """ |
||
34 | result = copy.deepcopy(d1) |
||
35 | |||
36 | for key, value in six.iteritems(d2): |
||
37 | if isinstance(value, dict): |
||
38 | result[key] = merge_dicts(result[key], value) |
||
39 | elif key not in result or value is not None: |
||
40 | result[key] = value |
||
41 | |||
42 | return result |
||
43 |