From da9f2a354a305a756360b27314cc21385c229584 Mon Sep 17 00:00:00 2001 From: mas2hc Date: Thu, 3 Aug 2023 17:55:05 +0700 Subject: [PATCH] Fix the issue cyclic imported JSON file --- JsonPreprocessor/CJsonPreprocessor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/JsonPreprocessor/CJsonPreprocessor.py b/JsonPreprocessor/CJsonPreprocessor.py index ca536060..60eec3f3 100644 --- a/JsonPreprocessor/CJsonPreprocessor.py +++ b/JsonPreprocessor/CJsonPreprocessor.py @@ -701,6 +701,8 @@ def __handleListElements(sInput : str) -> str: try: sJsonData= self.__load_and_removeComments(os.path.abspath(jFile)) except Exception as reason: + if masterFile: + self.__reset() raise Exception(f"Could not read json file '{jFile}' due to: '{reason}'!") sJsonDataUpdated = "" @@ -775,6 +777,8 @@ def __handleListElements(sInput : str) -> str: cls=CJSONDecoder, object_pairs_hook=self.__processImportFiles) except Exception as error: + if masterFile: + self.__reset() raise Exception(f"json file '{jFile}': '{error}'") oJson = __handleStrNoneTrueFalse(oJson) @@ -812,6 +816,7 @@ def __handleListElements(sInput : str) -> str: ldict = {} exec(sExec, globals(), ldict) except: + self.__reset() raise Exception(f"The variable '{parseNestedParam[0]}' is not available!") self.__reset()