Helper functions used by the Deis server.
api.utils.
dict_diff
(dict1, dict2)[source]¶Returns the added, changed, and deleted items in dict1 compared with dict2.
Parameters: |
|
---|---|
Returns: | a new dict, with ‘added’, ‘changed’, and ‘removed’ items if any were found. |
>>> d1 = {1: 'a'}
>>> dict_diff(d1, d1)
{}
>>> d2 = {1: 'a', 2: 'b'}
>>> dict_diff(d2, d1)
{'added': {2: 'b'}}
>>> d3 = {2: 'B', 3: 'c'}
>>> expected = {'added': {3: 'c'}, 'changed': {2: 'B'}, 'deleted': {1: 'a'}}
>>> dict_diff(d3, d2) == expected
True