Skip to content

Commit

Permalink
Removed the word 'nested' from the error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
namsonx committed Mar 22, 2024
1 parent 48eae0f commit 652e659
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
16 changes: 9 additions & 7 deletions JsonPreprocessor/CJsonPreprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def __loadNestedValue(initValue: str, sInputStr: str, bKey=False, key=''):
k = self.__nestedParamHandler(k, bKey=True)
if bImplicitCreation and not self.__checkAndCreateNewElement(k, v, bCheck=True, keyNested=keyNested):
self.__reset()
raise Exception(f"The implicit creation of data structures based on nested parameter is not supported. \
raise Exception(f"The implicit creation of data structures based on parameter is not supported. \
New parameter '{k}' could not be created by the expression '{keyNested}'")

if isinstance(v, dict):
Expand Down Expand Up @@ -921,7 +921,7 @@ def __recursiveNestedHandling(sInputStr: str, lNestedParam: list) -> str:
elif "," in sInputStr.strip()[:-1]:
if not re.match(r"^\s*\".+\"\s*$", sInputStr):
self.__reset()
raise Exception(f"Invalid nested parameter format: {sInputStr} - The double quotes are missing!!!")
raise Exception(f"Invalid parameter format: {sInputStr} - The double quotes are missing!!!")
listPattern = r"^\s*(\"*" + nestedPattern + r"\"*\s*,+\s*|" + valueStrPattern + r"\s*,+\s*|" + valueNumberPattern + r"\s*,+\s*)+" + \
r"(\"*" + nestedPattern + r"\"*\s*,*\s*|" + valueStrPattern + r"\s*,*\s*|" + valueNumberPattern + r"[\s,]*)*[\]}\s]*$"
lNestedParam = re.findall("(" + nestedPattern + ")", sInputStr, re.UNICODE)
Expand All @@ -935,7 +935,7 @@ def __recursiveNestedHandling(sInputStr: str, lNestedParam: list) -> str:
if "${" in item:
if not re.match(r"^[\s\"]*" + nestedPattern + r"[\"\]}\s]*$", item, re.UNICODE):
self.__reset()
raise Exception(f"Invalid nested parameter format: {item}")
raise Exception(f"Invalid parameter format: {item}")
elif re.match(r"^\s*\".*" + nestedPattern + r".*\"\s*$", item, re.UNICODE):
item = re.sub("(" + nestedPattern + ")", "\\1" + CNameMangling.STRINGCONVERT.value, item)
tmpList = []
Expand Down Expand Up @@ -1026,25 +1026,25 @@ def __checkNestedParam(self, sInput : str, bKey=False) -> bool:
raise Exception(errorMsg)
else:
return True
elif re.search(pattern2, sInput) or re.search(r"\[\s*\-\s*\d+\]", sInput):
elif re.search(pattern2, sInput) or re.search(r"\[\s*\-\s*\d+\s*\]", sInput):
errorMsg = f"Slicing is currently not supported! Please update the expression '{sInput}'."
self.__reset()
raise Exception(errorMsg)
elif CNameMangling.STRINGCONVERT.value in sInput:
if sInput.count("${") > sInput.count("}"):
sInput = re.sub(CNameMangling.STRINGCONVERT.value, "", sInput)
errorMsg = f"Invalid nested parameter format: {sInput.strip()}"
errorMsg = f"Invalid parameter format: {sInput.strip()}"
self.__reset()
raise Exception(errorMsg)
else:
return True
elif CNameMangling.STRINGCONVERT.value not in sInput and \
CNameMangling.DUPLICATEDKEY_01.value not in sInput:
if not re.match(r"^\${.+[}\]]+$", sInput) or (re.search(pattern1, sInput) and not bKey):
errorMsg = f"Invalid nested parameter format: {sInput} - The double quotes are missing!!!"
errorMsg = f"Invalid parameter format: {sInput} - The double quotes are missing!!!"
else:
if sInput.count("{") != sInput.count("}") or sInput.count("[") != sInput.count("]"):
errorMsg = f"Invalid nested parameter format: {sInput.strip()}"
errorMsg = f"Invalid parameter format: {sInput.strip()}"
else:
return True
self.__reset()
Expand Down Expand Up @@ -1257,6 +1257,8 @@ def __checkKeynameFormat(oJson : dict):
if re.search(r"(\s*\"str\(" + tmpNestedParam + "\)\"\s*:)", newLine.replace(CNameMangling.STRINGCONVERT.value, '')) \
or re.search(r"(\s*\"" + tmpNestedParam + r"\"\s*:)", newLine.replace(CNameMangling.STRINGCONVERT.value, '')):
self.lNestedParams.remove(nestedParam)
if re.search(r"\[\s*\+\s*\d+\s*\]", newLine):
newLine = re.sub(r"\[\s*\+\s*(\d+)\s*\]", "[\\1]", newLine)
sJsonDataUpdated = sJsonDataUpdated + newLine + "\n"
else:
sJsonDataUpdated = sJsonDataUpdated + line + "\n"
Expand Down
34 changes: 17 additions & 17 deletions test/testconfig/TestConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@
dictUsecase['HINT'] = "Checklist rule 2 / pattern 1"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0353.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -1533,7 +1533,7 @@
dictUsecase['HINT'] = "Checklist rule 2 / pattern 2"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0354.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -1547,7 +1547,7 @@
dictUsecase['HINT'] = "Checklist rule 2 / pattern 3"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0355.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -1561,7 +1561,7 @@
dictUsecase['HINT'] = "Checklist rule 2 / pattern 4"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0356.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand Down Expand Up @@ -1589,7 +1589,7 @@
dictUsecase['HINT'] = "Checklist rule 2 / pattern 6"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0358.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format" # wording to be improved (issues/109)
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format" # wording to be improved (issues/109)
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand Down Expand Up @@ -1617,7 +1617,7 @@
dictUsecase['HINT'] = "Checklist rule 2 / pattern 8"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0360.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand Down Expand Up @@ -1645,7 +1645,7 @@
dictUsecase['HINT'] = "Checklist rule 3 / pattern 2"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0362.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -1659,7 +1659,7 @@
dictUsecase['HINT'] = "Checklist rule 3 / pattern 3"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0363.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -1673,7 +1673,7 @@
dictUsecase['HINT'] = "Checklist rule 3 / pattern 4"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0364.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -1687,7 +1687,7 @@
dictUsecase['HINT'] = "Checklist rule 3 / pattern 5"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0365.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -1701,7 +1701,7 @@
dictUsecase['HINT'] = "Checklist rule 3 / pattern 6"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0366.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid nested parameter format"
dictUsecase['EXPECTEDEXCEPTION'] = "Invalid parameter format"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand Down Expand Up @@ -2612,7 +2612,7 @@
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1050.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on nested parameter is not supported"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on parameter is not supported"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -2626,7 +2626,7 @@
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1051.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on nested parameter is not supported"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on parameter is not supported"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -2640,7 +2640,7 @@
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1052.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on nested parameter is not supported"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on parameter is not supported"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand Down Expand Up @@ -2696,7 +2696,7 @@
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1056.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on nested parameter is not supported"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on parameter is not supported"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -2710,7 +2710,7 @@
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1057.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on nested parameter is not supported"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on parameter is not supported"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand All @@ -2724,7 +2724,7 @@
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1058.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on nested parameter is not supported"
dictUsecase['EXPECTEDEXCEPTION'] = "The implicit creation of data structures based on parameter is not supported"
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
del dictUsecase
Expand Down

0 comments on commit 652e659

Please sign in to comment.