diff --git a/deep_diff.py b/deep_diff.py index 13481a3..065f0b1 100644 --- a/deep_diff.py +++ b/deep_diff.py @@ -1,6 +1,6 @@ import json from copy import deepcopy - +from jay_diff import jay_diff_full, jay_merge_full def deep_diff(data, temp_data): new_data = {} @@ -37,16 +37,19 @@ def deep_merge(d, u, only_existing=True): if __name__ == '__main__': files = [ "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: + print(f"-----------------------------------------------------------------------------------------------------------------") + print(f"--- Using file {file}") + print(f"-----------------------------------------------------------------------------------------------------------------") with open(file, "r") as fp: src = json.load(fp) src_last = {} diffed_list = [] last = {} for s in src: - diffed = deep_diff(s, last) + diffed = jay_diff_full(last, s) diffed_list.append(deepcopy(diffed)) last = deepcopy(s) print(f"Diffed: {diffed}") @@ -54,10 +57,10 @@ if __name__ == '__main__': merged_list = [] last = {} for d in diffed_list: - merged = deep_merge(last, d) + merged = jay_merge_full(last, d) last = deepcopy(merged) merged_list.append(deepcopy(merged)) - print(f"Merged: {merged}") + # Check integrity assert src == merged_list diff --git a/jay_diff.py b/jay_diff.py index 318698f..7d5715a 100644 --- a/jay_diff.py +++ b/jay_diff.py @@ -48,7 +48,7 @@ def jay_diff_upd_add(_old, _new): return jay_diff_upd(_old, _new, add_if_not_exist=True) -def jay_diff_full(_old, _new, combine_upd_add): +def jay_diff_full(_old, _new, combine_upd_add=True): diff = {} if combine_upd_add: res = jay_diff_upd_add(_old, _new)