Skip to content

Commit

Permalink
correct code smels
Browse files Browse the repository at this point in the history
  • Loading branch information
DSungatulin committed Feb 23, 2024
1 parent 6af616a commit da6a1e8
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions gendiff/formatters/plain.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
from gendiff.formatters.format_determinant import get_data_format_plain


def get_data_format(value):
if isinstance(value, dict):
return '[complex value]'
if isinstance(value, bool):
return str(value).lower()
if isinstance(value, str):
return f"'{str(value)}'"
if value is None:
return 'null'
return str(value)


def get_plain_view(path, action, old_value, new_value):
beginning = f"Property '{path}' was"
if action == 'ADDED':
return f"{beginning} added with value: {get_data_format_plain(new_value)}"
if action == 'REMOVED':
return f"{beginning} removed"
if action == 'CHANGED':
return (
f"{beginning} updated. From {get_data_format_plain(old_value)} to {get_data_format_plain(new_value)}"
)
comparison_string = f"{beginning} added with value: {get_data_format_plain(new_value)}"
elif action == 'REMOVED':
comparison_string = f"{beginning} removed"
elif action == 'CHANGED':
comparison_string = (f"{beginning} updated. From {get_data_format_plain(old_value)} to {get_data_format_plain(new_value)}")
return comparison_string


def get_plained(diff):
Expand Down

0 comments on commit da6a1e8

Please sign in to comment.