Skip to content

Commit

Permalink
Merge pull request #13 from jyejare/fix_var_paths
Browse files Browse the repository at this point in the history
Fix the multiple recurrssion and improvize the id based comparision
  • Loading branch information
jyejare authored Mar 7, 2024
2 parents f3e5510 + 4c2b28e commit 142e3fb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions candore/modules/comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def record_variation(self, pre, post, var_details=None):
variation = {"pre": pre, "post": post, "variation": var_details or ""}
self.big_compare.update({full_path: variation})

def _is_data_type_dict(self, pre, post):
def _is_data_type_dict(self, pre, post, unique_key=""):
if (pre and 'id' in pre) and (post and 'id' in post):
# Dont compare the entities if the ids are not the same
if pre['id'] != post['id']:
return
for pre_key in pre:
if pre_key in post:
key = pre_key
Expand All @@ -56,6 +60,7 @@ def _is_data_type_dict(self, pre, post):
unique_key=pre_key,
var_details="Post lookup key missing",
)
self.remove_path(unique_key)

def _is_data_type_list(self, pre, post, unique_key=""):
for pre_entity in pre:
Expand Down Expand Up @@ -89,7 +94,7 @@ def compare_all_pres_with_posts(self, pre_data, post_data, unique_key="", var_de
if unique_key:
self.big_key.append(unique_key)
if type(pre_data) is dict:
self._is_data_type_dict(pre_data, post_data)
self._is_data_type_dict(pre_data, post_data, unique_key=unique_key)
elif type(pre_data) is list:
self._is_data_type_list(pre_data, post_data, unique_key=unique_key)
else:
Expand Down

0 comments on commit 142e3fb

Please sign in to comment.