-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc62362
commit be30af9
Showing
5 changed files
with
31 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |