Skip to content

Commit 1636e5b

Browse files
committed
add gendiff.search_of_the_diff.py
1 parent 6500318 commit 1636e5b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gendiff/search_of_the_diff.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import json
2+
3+
def search_diff(value1, value2):
4+
result = {}
5+
all_keys = sorted(list(value1.keys() | value2.keys()))
6+
for key in all_keys:
7+
if key in value1 and key not in value2:
8+
result[f'- {key}'] = value1.get(key)
9+
elif key in value1 and key in value2:
10+
if value1[key] == value2[key]:
11+
result[f' {key}'] = value1.get(key)
12+
else:
13+
result[f'- {key}'] = value1.get(key)
14+
result[f'+ {key}'] = value2.get(key)
15+
elif key not in value1 and key in value2:
16+
result[f'+ {key}'] = value2.get(key)
17+
return json.dumps(result)

0 commit comments

Comments
 (0)