Skip to content

Commit

Permalink
step 5
Browse files Browse the repository at this point in the history
  • Loading branch information
DSungatulin committed Jan 6, 2024
1 parent dc62362 commit be30af9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
19 changes: 19 additions & 0 deletions gendiff/engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from gendiff.json_diff import open_json
from gendiff.yaml_diff import open_yaml


def convert_bool_value(val):
bool_value = {'True': 'true', 'False': 'false'}
if isinstance(val, bool):
return bool_value[str(val)]
else:
return val


def format_decoder(filepath):
if filepath.endswith('json'):
return open_json(filepath)
elif filepath.endswith('yml') or filepath.endswith('yaml'):
return open_yaml(filepath)
else:
raise ValueError("Invalid file format!")
6 changes: 6 additions & 0 deletions gendiff/json_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import json


def open_json(filepath):
deserialized_file = json.load(open(filepath))
return deserialized_file
6 changes: 0 additions & 6 deletions gendiff/scripts/json_diff.py

This file was deleted.

6 changes: 0 additions & 6 deletions gendiff/scripts/yaml_diff.py

This file was deleted.

6 changes: 6 additions & 0 deletions gendiff/yaml_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import yaml


def open_yaml(filepath):
deserialized_file = yaml.safe_load(open(filepath))
return deserialized_file

0 comments on commit be30af9

Please sign in to comment.