Skip to content

Commit

Permalink
Ticket 370 - Missing parameter in dynamic import
Browse files Browse the repository at this point in the history
  • Loading branch information
namsonx committed Nov 14, 2024
1 parent 4dc0fd6 commit c9b9d40
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion JsonPreprocessor/CJsonPreprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ def __processImportFiles(self, input_data : dict) -> dict:
if '${' in value:
if self.bDuplicatedKeys: # self.bDuplicatedKeys is set False when handling pre-check JSON files by __preCheckJsonFile()
value = self.lDynamicImports.pop(0)
if '${' in value:
dynamicImported = re.search(rf'^(.*){CNameMangling.DYNAMICIMPORTED.value}(.*)$', value)
value = self.__removeTokenStr(dynamicImported[2])
nestedParams = re.findall(rf'(\${{[^{re.escape(self.specialCharacters)}]+}}(\[.*\])*)', value)
sParams = ''
for item in nestedParams:
sParams += f"{item[0]} "
errorMsg = f"Could not load the import file '{value}'. The parameter '{sParams}' is not available!"
self.__reset()
raise Exception(errorMsg)
else:
if re.match(r'^\[\s*import\s*\]$', key.strip()):
self.iDynamicImport +=1
Expand Down Expand Up @@ -1517,9 +1527,9 @@ def __preCheckJsonFile(self, sInput, CJSONDecoder):
self.__checkDotInParamName(self.jsonCheck)
oJson, bNested = self.__updateAndReplaceNestedParam(self.jsonCheck)
sJson = json.dumps(oJson)
sJson = self.__preCheckJsonFile(sJson, CJSONDecoder)
if sJson==tmpJson:
break
sJson = self.__preCheckJsonFile(sJson, CJSONDecoder)
sInput = sJson
return sInput

Expand Down

0 comments on commit c9b9d40

Please sign in to comment.