/
__init__.py
66 lines (53 loc) · 1.9 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
This package allows to compute deep differences between two python dictionnaries
Differences are stored in the following format :
lhs stands for Left Hand Side
rhs stands for Right Hand Side
- Creation : {'path':path_to_object,'kind':'N','rhs':value}
- Deletion : {'path':path_to_object,'kind':'D','lhs':value}
- Edition : {'path':path_to_object,'kind':'E','lhs':value,'rhs':value}
- Lists
- Creation : {'path':path_to_object,'kind':'N','rhs_idx':index,'rhs':value}
- Deletion : {'path':path_to_object,'kind':'D','lhs_idx':index,'lhs':value}
- Move : {'path':path_to_object,'kind':'M','lhs_idx':index,'rhs_idx':index}
Example of use :
from pydeepdiff.diff import get_diff
dict_a = {'field_1': 'id1', 'field_2': 'vala1'}
dict_b = {'field_1': 'id3', 'field_2': 'valb1'}
differences = get_diff(dict_a, dict_b)
# Differences contains one difference :
[
{
'path': [
'field_1'
],
'kind': 'E',
'lhs': 'id1',
'rhs': 'id3'
},
{
'path': [
'field_2'
],
'kind': 'E',
'lhs': 'vala1',
'rhs': 'valb1'
}
]
dict_a = {'id': '1', 'bloc': {'act': '1'}}
dict_b = {'id': '1', 'bloc': {'act': '2'}}
differences = get_diff(dict_a, dict_b))
# Differences contains one difference :
[
{
'path': [
'bloc',
'act'
],
'kind': 'E',
'lhs': '1',
'rhs': '2'
}
]
"""
__version__ = "1.0.1"