Skip to content

Commit

Permalink
Fix json-bools
Browse files Browse the repository at this point in the history
  • Loading branch information
remortalite committed Jun 17, 2024
1 parent 22a384b commit 5be0873
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gendiff/formatters/stylish.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
from itertools import chain


CENSORED_JSON_DICT = {
True: "true",
False: "false",
None: "null"
}

def _format_stylish(data, indent_symbol=" ", indent_size=4):
def iter_(current_data, level=1):
if not isinstance(current_data, dict):
Expand All @@ -18,7 +24,10 @@ def iter_(current_data, level=1):
strings.append(f"{indent_symbol * indent_size * level}")
strings[-1] += "}"
else:
strings[-1] += f"{current_data[el]}"
if isinstance(current_data[el], bool):
strings[-1] += f"{CENSORED_JSON_DICT[current_data[el]]}"
else:
strings[-1] += f"{current_data[el]}"
return '\n'.join(strings) if data else data
return f"{{\n{iter_(data)}\n}}" if data else data

Expand Down

0 comments on commit 5be0873

Please sign in to comment.