[deep_diff]

- alse check combine_upd_add
This commit is contained in:
2024-10-20 13:43:09 +02:00
parent a28a24821a
commit 6ade6563eb
+23 -22
View File
@@ -39,28 +39,29 @@ if __name__ == '__main__':
"results/WVWZZZE1ZMP010760/2024/10/18/vehicle_WVWZZZE1ZMP010760_2024-10-15T12-05-23-268Z.json", "results/WVWZZZE1ZMP010760/2024/10/18/vehicle_WVWZZZE1ZMP010760_2024-10-15T12-05-23-268Z.json",
"results/WVWZZZE1ZMP010760/2024/10/19/vehicle_WVWZZZE1ZMP010760_2024-10-19T00-00-34-353Z.json", "results/WVWZZZE1ZMP010760/2024/10/19/vehicle_WVWZZZE1ZMP010760_2024-10-19T00-00-34-353Z.json",
] ]
for file in files: for diff_mode_update_add in [True, False]:
print(f"-----------------------------------------------------------------------------------------------------------------") for file in files:
print(f"--- Using file {file}") print(f"-----------------------------------------------------------------------------------------------------------------")
print(f"-----------------------------------------------------------------------------------------------------------------") print(f"--- Using file {file}, diff_mode_update_add={diff_mode_update_add}")
with open(file, "r") as fp: print(f"-----------------------------------------------------------------------------------------------------------------")
src = json.load(fp) with open(file, "r") as fp:
src_last = {} src = json.load(fp)
diffed_list = [] src_last = {}
last = {} diffed_list = []
for s in src: last = {}
diffed = jay_diff_full(last, s) for s in src:
diffed_list.append(deepcopy(diffed)) diffed = jay_diff_full(last, s, combine_upd_add=diff_mode_update_add)
last = deepcopy(s) diffed_list.append(deepcopy(diffed))
print(f"Diffed: {diffed}") last = deepcopy(s)
print(f"Diffed: {diffed}")
merged_list = [] merged_list = []
last = {} last = {}
for d in diffed_list: for d in diffed_list:
merged = jay_merge_full(last, d) merged = jay_merge_full(last, d)
last = deepcopy(merged) last = deepcopy(merged)
merged_list.append(deepcopy(merged)) merged_list.append(deepcopy(merged))
# Check integrity # Check integrity
assert src == merged_list assert src == merged_list