| Conditions | 4 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | import json |
||
| 7 | def merge_dict(d1, d2): |
||
| 8 | """ |
||
| 9 | Modifies d1 in-place to contain values from d2. If any value |
||
| 10 | in d1 is a dictionary (or dict-like), *and* the corresponding |
||
| 11 | value in d2 is also a dictionary, then merge them in-place. |
||
| 12 | """ |
||
| 13 | for k,v2 in d2.items(): |
||
| 14 | v1 = d1.get(k) # returns None if v1 has no value for this key |
||
| 15 | if (isinstance(v1, collections.Mapping) |
||
| 16 | and isinstance(v2, collections.Mapping)): |
||
| 17 | merge_dict(v1, v2) |
||
| 18 | else: |
||
| 19 | d1[k] = v2 |
||
| 20 | |||
| 29 |