From 029e418260cf62ab1bd4f87dce613e086600e53a Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 29 Sep 2022 19:14:47 +0200 Subject: [PATCH] Created json utilities --- .../Files/Json/__init__.py | 0 Utilities/Files/Json/json_utils.py | 15 ++++++++++++ Utilities/file_parser.py | 23 ------------------- 3 files changed, 15 insertions(+), 23 deletions(-) rename Plotter/plotter.py => Utilities/Files/Json/__init__.py (100%) create mode 100644 Utilities/Files/Json/json_utils.py delete mode 100644 Utilities/file_parser.py diff --git a/Plotter/plotter.py b/Utilities/Files/Json/__init__.py similarity index 100% rename from Plotter/plotter.py rename to Utilities/Files/Json/__init__.py diff --git a/Utilities/Files/Json/json_utils.py b/Utilities/Files/Json/json_utils.py new file mode 100644 index 0000000..0a54c33 --- /dev/null +++ b/Utilities/Files/Json/json_utils.py @@ -0,0 +1,15 @@ +# Python Imports +import json +import jsonschema + + +def read_json(file_path): + with open(file_path, "r") as file: + json_content = json.load(file) + + return json_content + + +def validate_json(json_content, json_schema): + jsonschema.validate(instance=json_content, schema=json_schema) + diff --git a/Utilities/file_parser.py b/Utilities/file_parser.py deleted file mode 100644 index 7725f2e..0000000 --- a/Utilities/file_parser.py +++ /dev/null @@ -1,23 +0,0 @@ -import json - - -class ConfigurationFileParser: - - def __init__(self, file_path): - self._file_path = file_path - - def read_content(self): - # Retrieve raw info - data = self._parse_file() - - # Check valid flags depending on simulation () - print("asd") - # Parse values - - return "data" - - def _parse_file(self): - with open(self._file_path, "r") as file: - data = json.load(file) - - return data