Skip to content

Commit

Permalink
Implement
Browse files Browse the repository at this point in the history
  • Loading branch information
disrupted committed Jul 9, 2024
1 parent 7e71343 commit b23336f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions kpops/utils/dict_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,31 @@ def __find_changed_key(key_1: list[str] | str, key_2: str = "") -> str:


def render_diff(d1: Mapping, d2: Mapping, ignore: set[str] | None = None) -> str | None:
d1 = dict(d1)
d2 = dict(d2)

def del_ignored_keys(d: dict) -> None:
"""Delete key to be ignored, dictionary is modified in-place."""
if ignore:
for i in ignore:
key_path = i.split(".")
nested = d1
try:
for key in key_path[:-1]:
nested = nested[key]
del nested[key_path[-1]]
except KeyError:
continue

del_ignored_keys(d1)
del_ignored_keys(d2)

differences = list(diff(d1, d2, ignore=ignore))
if not differences:
return None

d2_filtered: Mapping = patch(differences, d1)

return "".join(
colorize_diff(
differ.compare(
Expand Down

0 comments on commit b23336f

Please sign in to comment.