diff --git a/JsonPreprocessor/CJsonPreprocessor.py b/JsonPreprocessor/CJsonPreprocessor.py index 69ea01f..fec07d9 100644 --- a/JsonPreprocessor/CJsonPreprocessor.py +++ b/JsonPreprocessor/CJsonPreprocessor.py @@ -75,6 +75,8 @@ class CNameMangling(Enum): STRINGVALUE = "__StringValueMake-up__" HANDLEIMPORTED = "__CheckImportedHandling__" DYNAMICIMPORTED = "__DynamicImportedHandling__" + PYTHONBUILTIN = "__PythonBuiltInFunction__" + PYBUILTINSTR = "__StrInPythonInlineCode__" class CPythonJSONDecoder(json.JSONDecoder): """ @@ -156,7 +158,7 @@ def __init__(self, keyPattern): def keyNameChecker(self, sKeyName: str): if sKeyName=='' or regex.match(r'^\s+$', sKeyName): - self.errorMsg = f"Empty key name detected. Please enter a valid name." + self.errorMsg = "Empty key name detected. Please enter a valid name." return False if regex.match(self.keyPattern, sKeyName): return True @@ -386,7 +388,7 @@ def __init__(self, syntax: CSyntaxType = CSyntaxType.python , currentCfg : dict self.keyPattern = keyPattern self.lDataTypes = [name for name, value in vars(builtins).items() if isinstance(value, type)] self.specialCharacters = r"!#$%^&()=[]{}|;',?`~" - self.pyCallPattern = r'<<\s*eval(?:(?!<<\s*eval|>>).)*>>' # The pattern of call Python builtin function in JSONP + self.pyCallPattern = r'<<\s*(?:(?!<<\s*|>>).)*>>' # The pattern of call Python builtin function in JSONP self.lDataTypes.append(keyword.kwlist) self.jsonPath = None self.importTree = None @@ -649,7 +651,7 @@ def __checkParamName(self, sInput: str) -> str: / *Type*: str / """ - pattern = rf'\${{\s*([^\[]+)\s*}}' + pattern = r'\${\s*([^\[]+)\s*}' lParams = regex.findall(pattern, sInput, regex.UNICODE) for param in lParams: if "." not in param and param in self.lDataTypes: @@ -750,9 +752,12 @@ def __getNestedValue(sNestedParam : str): oTmpObj = oTmpObj[int(element)] i+=1 try: - ldict = {} - exec(sExec, locals(), ldict) - tmpValue = ldict['value'] + if bPyBuiltIn: + tmpValue = sExec.replace('value = ', '') + else: + ldict = {} + exec(sExec, locals(), ldict) + tmpValue = ldict['value'] except Exception as error: if self.bJSONPreCheck: sNestedParam = self.__removeTokenStr(sNestedParam) @@ -769,7 +774,7 @@ def __getNestedValue(sNestedParam : str): errorMsg = f"{errorMsg} Reason: {error}" if ' or slices' not in str(error) else \ f"{errorMsg} Reason: {str(error).replace(' or slices', '')}" else: - if isinstance(error, KeyError) and regex.search(r"\[\s*" + str(error) + "\s*\]", sNestedParam): + if isinstance(error, KeyError) and regex.search(r"\[\s*" + str(error) + r"\s*\]", sNestedParam): errorMsg = f"Could not resolve expression '{sNestedParam.replace('$${', '${')}'. \ Reason: Key error {error}" else: @@ -778,7 +783,7 @@ def __getNestedValue(sNestedParam : str): return tmpValue bPyBuiltIn = False - if regex.match(self.pyCallPattern, sInputStr): + if regex.search(self.pyCallPattern, sInputStr): bPyBuiltIn = True specialCharacters = r'[]{}' pattern = rf'\$\${{\s*[^{regex.escape(specialCharacters)}]+\s*}}' @@ -1286,7 +1291,7 @@ def __handleList(lInput : list, bNested : bool, parentParams : str = '') -> list oJson = self.currentCfg | oJson tmpJson = copy.deepcopy(oJson) - pattern = rf"\${{\s*[^\[]+\s*}}" + pattern = r"\${\s*[^\[]+\s*}" pattern = rf"{pattern}(\[+\s*'.+'\s*\]+|\[+\s*\d+\s*\]+|\[+\s*\${{.+\s*\]+)*" for k, v in tmpJson.items(): if "${" not in k and CNameMangling.DUPLICATEDKEY_01.value not in k: @@ -1408,13 +1413,11 @@ def __handleList(lInput : list, bNested : bool, parentParams : str = '') -> list elif isinstance(v, list): v = __handleList(v, bNested, parentParams) elif isinstance(v, str) and self.__checkNestedParam(v): + bPyBuiltIn = False # Check and handle the Python builtIn in JSONP - if regex.match(self.pyCallPattern, v): - if regex.match(r'^\s*<<\s*eval\s*>>\s*$', v): - errorMsg = f"The Python builtIn must not be empty. Please check '{self.__removeTokenStr(v)}'" - self.__reset() - raise Exception(errorMsg) - elif "${" not in v: + if regex.search(self.pyCallPattern, v): + bPyBuiltIn = True + if '${' not in v: try: v = self.__pyBuiltInHandle(v) except Exception as error: @@ -1445,7 +1448,8 @@ def __handleList(lInput : list, bNested : bool, parentParams : str = '') -> list raise Exception(errorMsg) v = __loadNestedValue(initValue, v, key=k) # Check and handle the Python builtIn in JSONP - if isinstance(v, str) and regex.match(self.pyCallPattern, v): + if isinstance(v, str) and regex.search(self.pyCallPattern, v): + bPyBuiltIn = True try: v = self.__pyBuiltInHandle(v) except Exception as error: @@ -1466,7 +1470,7 @@ def __handleList(lInput : list, bNested : bool, parentParams : str = '') -> list raise Exception(f"Invalid expression found: '{self.__removeTokenStr(initValue)}'.") else: break - if isinstance(v, str) and regex.search(r'\[[^\]]+\]', v): + if isinstance(v, str) and regex.search(r'\[[^\]]+\]', v) and not bPyBuiltIn: sExec = 'value = ' + v try: ldict = {} @@ -1511,7 +1515,7 @@ def __handleList(lInput : list, bNested : bool, parentParams : str = '') -> list parentParams = '' __jsonUpdated(k, v, oJson, parentParams, keyNested, paramInValue, bDuplicatedHandle, recursive) if keyNested is not None and not bStrConvert: - transTable = str.maketrans({"[":"\[", "]":"\]" }) + transTable = str.maketrans({"[":r"\[", "]":r"\]" }) tmpList = [] for key in self.dUpdatedParams: if regex.match(r"^" + k.translate(transTable) + r"\['.+$", key, regex.UNICODE): @@ -1560,7 +1564,7 @@ def __checkNestedParam(self, sInput : str, bKey=False) -> bool: *raise exception if nested parameter format invalid* """ pattern = rf"^\${{\s*[^{regex.escape(self.specialCharacters)}]+\s*}}(\[.*\])+$" - pattern1 = rf"\${{[^\${{]+}}(\[[^\[]+\])*[^\[]*\${{" + pattern1 = r"\${[^\${]+}(\[[^\[]+\])*[^\[]*\${" pattern2 = r"\[[\p{Nd}\.\-\+'\s]*:[\p{Nd}\.\-\+'\s]*\]|\[[\s\p{Nd}\+\-]*\${.+[}\]][\s\p{Nd}\+\-]*:[\s\p{Nd}\+\-]*\${.+[}\]][\s\p{Nd}\+\-]*\]|" # Slicing pattern pattern2 = pattern2 + r"\[[\s\p{Nd}\+\-]*\${.+[}\]][\s\p{Nd}\+\-]*:[\p{Nd}\.\-\+'\s]*\]|\[[\p{Nd}\.\-\+'\s]*:[\s\p{Nd}\+\-]*\${.+[}\]][\s\p{Nd}\+\-]*\]" # Slicing pattern if not bKey and regex.match(self.pyCallPattern, sInput): @@ -1823,7 +1827,7 @@ def hashContent(sInput : str) -> str: self.__reset() raise Exception(jsonException) self.JPGlobals = self.jsonCheck - importPattern = rf'([\'|"]\s*\[\s*import\s*\](_\d+)*\s*[\'|"]\s*:\s*[\'|"][^\'"]+[\'|"])' + importPattern = r'([\'|"]\s*\[\s*import\s*\](_\d+)*\s*[\'|"]\s*:\s*[\'|"][^\'"]+[\'|"])' sJson = json.dumps(self.jsonCheck) # Check cyclic import by comparing the content of the whole JSONP configuration object. if len(self.importCheck)>1: @@ -1850,15 +1854,59 @@ def __pyBuiltInHandle(self, sInput : str): """ Handles Python builtIn function. """ - sExec = regex.sub(r'<<\s*eval(.*)>>', "evalValue = \\1", sInput) + if CNameMangling.PYBUILTINSTR.value in sInput: + sInput = sInput.replace(CNameMangling.PYBUILTINSTR.value, '"') + if CNameMangling.PYTHONBUILTIN.value in sInput: + sInput = regex.sub(rf'(self\.JPGlobals(?:(?!self\.JPGlobals).)+){CNameMangling.PYTHONBUILTIN.value}', '"\\1"', sInput) + pyInlineCode = regex.findall(self.pyCallPattern, sInput)[0] + sExec = regex.sub(r'<<\s*(.*)>>', "evalValue = \\1", pyInlineCode) try: ldict = {} exec(sExec, locals(), ldict) evalValue = ldict['evalValue'] except Exception as error: raise Exception(error) - + if not isinstance(evalValue, (str, int, float, bool, type(None), list, dict)): + errorMsg = f"The Python builtIn '{self.__removeTokenStr(sInput)}' return the value with \ +the datatype '{type(evalValue)}' is not suitable for JSON." + raise Exception(errorMsg) + if CNameMangling.DYNAMICIMPORTED.value in sInput: + sInput = regex.sub(f'{CNameMangling.DYNAMICIMPORTED.value}', '/', sInput) + sInput = regex.sub(f'{self.pyCallPattern}', f'{evalValue}', sInput) + evalValue = sInput + return evalValue + + def __pyInlineCodeSyntaxCheck(self, sInput): + """ +Checks the syntax of Python inline code. + """ + if regex.match(r'^\s*<<\s*>>\s*$', sInput): + errorMsg = f"The Python builtIn must not be empty. Please check '{self.__removeTokenStr(v)}'" + self.__reset() + raise Exception(errorMsg) + elif regex.search(rf'["\s]*{self.pyCallPattern}[^:]*["\s]*:', sInput): + errorMsg = f"Python inline code is not allowed as key! Please check the line {sInput}" + self.__reset() + raise Exception(errorMsg) + elif regex.search(rf':\s*".*{self.pyCallPattern}[^"]*"', sInput): + errorMsg = f"Python inline code must not be embedded part of a string! Please check the line {sInput}" + self.__reset() + raise Exception(errorMsg) + else: + pyInlineCode = regex.search(self.pyCallPattern, sInput) + if len(pyInlineCode) > 0: + pyInlineCode = pyInlineCode[0] + if pyInlineCode.count('"') % 2 == 1: + errorMsg = f"Invalid syntax in the Python inline code '{pyInlineCode}'." + self.__reset() + raise Exception(errorMsg) + elif regex.search(r'"\s*\${[^"]+"', pyInlineCode): + pyInlineCode = regex.sub(r'"\s*(\${[^"]+)\s*"', f'\\1{CNameMangling.PYTHONBUILTIN.value}', pyInlineCode) + pyInlineCode = regex.sub(r'"(\s*(?:(?!\${)[^"])*)"', \ + f'{CNameMangling.PYBUILTINSTR.value}\\1{CNameMangling.PYBUILTINSTR.value}', pyInlineCode) + sInput = regex.sub(rf'({self.pyCallPattern})', f'"{pyInlineCode}"', sInput) + return sInput def jsonLoad(self, jFile : str): """ @@ -2083,7 +2131,7 @@ def __handleLastElement(sInput : str) -> str: raise Exception(f"{error} in line: '{line}'") line = line.rstrip() if regex.search(self.pyCallPattern, line): - line = regex.sub(rf'({self.pyCallPattern})', '"\\1"', line) + line = self.__pyInlineCodeSyntaxCheck(line) if "${" in line: line = regex.sub(r'\${\s*([^\s][^}]+[^\s])\s*}', '${\\1}', line) curLine = line @@ -2131,6 +2179,7 @@ def __handleLastElement(sInput : str) -> str: item = item.replace(CNameMangling.NESTEDPARAM.value, tmpList03.pop(0)) curItem = item if "${" in item: + tmpList = [] bHandle = False if '"' in item and item.count('"')%2==0: tmpList = regex.findall(r'"[^"]+"', item) @@ -2178,9 +2227,9 @@ def __handleLastElement(sInput : str) -> str: item = __handleLastElement(item) elif not regex.match(r'^[\s{]*"[^"]*"\s*$', item): if CNameMangling.STRINGVALUE.value in item: - item = regex.sub('(^[\s{]*)([^\s].+[^\s])\s*$', '\\1\'\\2\' ', item) + item = regex.sub(r'(^[\s{]*)([^\s].+[^\s])\s*$', '\\1\'\\2\' ', item) else: - item = regex.sub('(^[\s{]*)([^\s].+[^\s])\s*$', '\\1"\\2" ', item) + item = regex.sub(r'(^[\s{]*)([^\s].+[^\s])\s*$', '\\1"\\2" ', item) while CNameMangling.STRINGVALUE.value in item: if "${" in tmpList[0]: sValue = tmpList.pop(0) diff --git a/JsonPreprocessor/JsonPreprocessor.pdf b/JsonPreprocessor/JsonPreprocessor.pdf index 2e05d68..761c1d7 100644 Binary files a/JsonPreprocessor/JsonPreprocessor.pdf and b/JsonPreprocessor/JsonPreprocessor.pdf differ diff --git a/JsonPreprocessor/version.py b/JsonPreprocessor/version.py index 05969b4..760e491 100644 --- a/JsonPreprocessor/version.py +++ b/JsonPreprocessor/version.py @@ -18,5 +18,5 @@ # # Version and date of JsonPreprocessor # -VERSION = "0.9.3" -VERSION_DATE = "3.7.2025" +VERSION = "0.10.0" +VERSION_DATE = "25.07.2025" diff --git a/config/robotframework_aio/release_items_JsonPreprocessor.json b/config/robotframework_aio/release_items_JsonPreprocessor.json index a1fbc4f..9ea2f45 100644 --- a/config/robotframework_aio/release_items_JsonPreprocessor.json +++ b/config/robotframework_aio/release_items_JsonPreprocessor.json @@ -1,6 +1,6 @@ # ************************************************************************************************************** # -# Copyright 2020-2023 Robert Bosch GmbH +# Copyright 2020-2025 Robert Bosch GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -202,6 +202,23 @@ This feature is an option. If the user does not define the parameter ``keyPatter * Improved and aligned error messages * Added and updated the self test according to the changed features " - ] + ], + "0.14.2.;0.15.0." : [ +" +**Python inline code** + +**JsonPreprocessor** enables to use Python inline code inside JSONP files. + +*Example* + +| ``\"A\" : [1,2,3],`` +| ``\"B\" : [4,5,6],`` +| ``\"C\" : <<${A} + ${B}>>`` + +*Result* + +| ``DotDict({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [1, 2, 3, 4, 5, 6]})`` +" + ] } } diff --git a/packagedoc/additional_docs/History.tex b/packagedoc/additional_docs/History.tex index cfb9b9e..6c50ac9 100644 --- a/packagedoc/additional_docs/History.tex +++ b/packagedoc/additional_docs/History.tex @@ -112,4 +112,7 @@ \historychange{- Allowed unicode digits to get a list element\newline - Updated error messages} +\historyversiondate{0.10.0}{07/2025} +\historychange{Added possibility to use Python inline code inside JSONP files} + \end{packagehistory} diff --git a/packagedoc/additional_docs/The JSONP format.tex b/packagedoc/additional_docs/The JSONP format.tex index 70e8748..a7f838d 100644 --- a/packagedoc/additional_docs/The JSONP format.tex +++ b/packagedoc/additional_docs/The JSONP format.tex @@ -1188,8 +1188,6 @@ \section{Dynamic key names} A substitution in key names is not allowed! Please update the key name "${strval}_2" \end{pythonlog} - - % -------------------------------------------------------------------------------------------------------------- \newpage @@ -1369,12 +1367,109 @@ \section{Implicit creation of dictionaries}\label{implicit-creation} } \end{pythoncode} +% -------------------------------------------------------------------------------------------------------------- + +\newpage + +\section{Python inline code} + +It might be required to have access to Python builtin functions, e.g. for combining multiple lists into a single list. +In pure Python this can be realized in the following way: +\begin{pythoncode} +A = [1,2,3] +B = [4,5,6] +C = A + B +print(C) +\end{pythoncode} +With result: +\begin{pythonlog} +[1, 2, 3, 4, 5, 6] +\end{pythonlog} +In JSONP files, the implementation looks as follows: + +\begin{pythoncode} +"A" : [1,2,3], +"B" : [4,5,6], +"C" : <\textless{}\textless{}>${A} + ${B}<\textgreater{}\textgreater{}> +\end{pythoncode} + +The expression \pcode{$\{A\} + $\{B\}} is handled as Python inline code. It is possible to use dollar operator expressions +inside Python inline code to access any other parameter defined in JSONP files. + +\vspace{2ex} + +The syntax of Python inline code is: + +\begin{pythoncode} +<\textless{}\textless{}><(\emph{Python expression})><\textgreater{}\textgreater{}> +\end{pythoncode} + +\vspace{2ex} + +\textbf{Limitations} + +The Python inline code syntax cannot be used within strings. The following code is invalid: + +\begin{pythoncode} +"param" : "The value is <\textless{}\textless{}><(\emph{Python expression})><\textgreater{}\textgreater{}>" +\end{pythoncode} + +The usage of Python inline code is limited to the right hand side of the colon (\emph{key values}). +This feature cannot be used to create key names. + +Python inline code cannot be used immediately to select list elements or dictionary keys that shall be overwritten. The following code is invalid: + +\begin{pythoncode} +"param" : [1,2,3], +${param}[<\textless{}\textless{}>0 if True else 1<\textgreater{}\textgreater{}>] : 4 +\end{pythoncode} + +This is a possible workaround: + +\begin{pythoncode} +"param" : [1,2,3], +"index" : <\textless{}\textless{}>0 if True else 1<\textgreater{}\textgreater{}>, +${param}[${index}] : 4 +\end{pythoncode} + +% TODO when supported by JsonPreprocessor: + +% Python inline code can only be used to return values of data types supported by the JSON format. The following Python inline code returns a \pcode{datetime} object +% and therefore is invalid: + +% \begin{pythoncode} +% "now" : <\textless{}\textless{}>from datetime import datetime; now = datetime.now()<\textgreater{}\textgreater{}> +% \end{pythoncode} + +\vspace{2ex} + +\textbf{Further examples} + +\textit{Create a list of dictionary keys:} + +\begin{pythoncode} +"dict" : {"kA" : "vA", "kB" : "vB"}, +"key_list" : <\textless{}\textless{}>list(${dict}.keys())<\textgreater{}\textgreater{}> +\end{pythoncode} + +\textit{Define an import path:} + +\begin{pythoncode} +"path_1" : "./file_1.jsonp", +"path_2" : "./file_2.jsonp" +// +"[import]" : <\textless{}\textless{}>${path_1} if True else ${path_2}<\textgreater{}\textgreater{}> +\end{pythoncode} +% TODO when supported by JsonPreprocessor: + % // Python inline code with import of an additional module + % "element" : <> + % C:\workplace\ROBFW\components\python-jsonpreprocessor\test\testfiles\jpp-test_config_2108.jsonp % -------------------------------------------------------------------------------------------------------------- diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 4cbf5d3..713303d 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -202,3 +202,17 @@ JPP_2055|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing s JPP_2056|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (7) JPP_2057|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (8) JPP_2058|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (9) +JPP_2100|INLINE_CODE|GOODCASE|JSON file containing Python inline code with simple data types +JPP_2101|INLINE_CODE|GOODCASE|JSON file containing Python inline code with composite data types +JPP_2102|INLINE_CODE|GOODCASE|JSON file containing Python inline code with simple conditions +JPP_2103|INLINE_CODE|GOODCASE|JSON file containing Python inline code within lists and dictionaries +JPP_2105|INLINE_CODE|GOODCASE|JSON file containing Python inline code in more complex scenarios +JPP_2107|INLINE_CODE|GOODCASE|JSON file containing Python inline code with import paths +JPP_2150|INLINE_CODE|BADCASE|Python inline code as embedded part of a string (1) +JPP_2151|INLINE_CODE|BADCASE|Python inline code as embedded part of a string (2) +JPP_2152|INLINE_CODE|BADCASE|Python inline code as embedded part of a string (3) +JPP_2180|INLINE_CODE|BADCASE|Python inline code with additional leading angle bracket +JPP_2184|INLINE_CODE|BADCASE|Python inline code inside a dictionary with additional leading angle bracket +JPP_2192|INLINE_CODE|BADCASE|Python inline code is parameter name +JPP_2193|INLINE_CODE|BADCASE|Python inline code is parameter name inside a list +JPP_2194|INLINE_CODE|BADCASE|Python inline code is parameter name inside a dictionary diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index d201679..14cbea2 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -6737,12 +6737,474 @@ + + + + + +203 + + + + + +JPP_2100 + + + + +INLINE_CODE + + + + +GOODCASE + + + + +JSON file containing Python inline code with simple data types
+Expected: JsonPreprocessor returns expected values + + +
+ + + + + + + +204 + + + + + +JPP_2101 + + + + +INLINE_CODE + + + + +GOODCASE + + + + +JSON file containing Python inline code with composite data types
+Expected: JsonPreprocessor returns expected values + + +
+ + + + + + + +205 + + + + + +JPP_2102 + + + + +INLINE_CODE + + + + +GOODCASE + + + + +JSON file containing Python inline code with simple conditions
+Expected: JsonPreprocessor returns expected values + + +
+ + + + + + + +206 + + + + + +JPP_2103 + + + + +INLINE_CODE + + + + +GOODCASE + + + + +JSON file containing Python inline code within lists and dictionaries
+Expected: JsonPreprocessor returns expected values + + +
+ + + + + + + +207 + + + + + +JPP_2105 + + + + +INLINE_CODE + + + + +GOODCASE + + + + +JSON file containing Python inline code in more complex scenarios
+Expected: JsonPreprocessor returns expected values + + +
+ + + + + + + +208 + + + + + +JPP_2107 + + + + +INLINE_CODE + + + + +GOODCASE + + + + +JSON file containing Python inline code with import paths
+Expected: JsonPreprocessor returns expected values + + +
+ + + + + + + +209 + + + + + +JPP_2150 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code as embedded part of a string (1)
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +210 + + + + + +JPP_2151 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code as embedded part of a string (2)
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +211 + + + + + +JPP_2152 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code as embedded part of a string (3)
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +212 + + + + + +JPP_2180 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code with additional leading angle bracket
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +213 + + + + + +JPP_2184 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code inside a dictionary with additional leading angle bracket
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +214 + + + + + +JPP_2192 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code is parameter name
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +215 + + + + + +JPP_2193 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code is parameter name inside a list
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +216 + + + + + +JPP_2194 + + + + +INLINE_CODE + + + + +BADCASE + + + + +Python inline code is parameter name inside a dictionary
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ +
 

-
Generated: 10.04.2025 - 17:21:06
+
Generated: 11.08.2025 - 16:48:21
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index 51ec9ce..26fe29f 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -2125,5 +2125,145 @@ Test Use Cases ---- -Generated: 10.04.2025 - 17:21:06 +* **Test JPP_2100** + + [INLINE_CODE / GOODCASE] + + **JSON file containing Python inline code with simple data types** + + Expected: JsonPreprocessor returns expected values + +---- + +* **Test JPP_2101** + + [INLINE_CODE / GOODCASE] + + **JSON file containing Python inline code with composite data types** + + Expected: JsonPreprocessor returns expected values + +---- + +* **Test JPP_2102** + + [INLINE_CODE / GOODCASE] + + **JSON file containing Python inline code with simple conditions** + + Expected: JsonPreprocessor returns expected values + +---- + +* **Test JPP_2103** + + [INLINE_CODE / GOODCASE] + + **JSON file containing Python inline code within lists and dictionaries** + + Expected: JsonPreprocessor returns expected values + +---- + +* **Test JPP_2105** + + [INLINE_CODE / GOODCASE] + + **JSON file containing Python inline code in more complex scenarios** + + Expected: JsonPreprocessor returns expected values + +---- + +* **Test JPP_2107** + + [INLINE_CODE / GOODCASE] + + **JSON file containing Python inline code with import paths** + + Expected: JsonPreprocessor returns expected values + +---- + +* **Test JPP_2150** + + [INLINE_CODE / BADCASE] + + **Python inline code as embedded part of a string (1)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_2151** + + [INLINE_CODE / BADCASE] + + **Python inline code as embedded part of a string (2)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_2152** + + [INLINE_CODE / BADCASE] + + **Python inline code as embedded part of a string (3)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_2180** + + [INLINE_CODE / BADCASE] + + **Python inline code with additional leading angle bracket** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_2184** + + [INLINE_CODE / BADCASE] + + **Python inline code inside a dictionary with additional leading angle bracket** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_2192** + + [INLINE_CODE / BADCASE] + + **Python inline code is parameter name** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_2193** + + [INLINE_CODE / BADCASE] + + **Python inline code is parameter name inside a list** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_2194** + + [INLINE_CODE / BADCASE] + + **Python inline code is parameter name inside a dictionary** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +Generated: 11.08.2025 - 16:48:21 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index 73e9a1c..3a61a79 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -868,5 +868,61 @@ Test JPP_2058 / PARAMETER_SCOPE / BADCASE Description: JSON file containing a parameter with missing scope (9) Expectation: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ -Generated: 10.04.2025 - 17:21:06 +Test JPP_2100 / INLINE_CODE / GOODCASE +Description: JSON file containing Python inline code with simple data types +Expectation: JsonPreprocessor returns expected values +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2101 / INLINE_CODE / GOODCASE +Description: JSON file containing Python inline code with composite data types +Expectation: JsonPreprocessor returns expected values +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2102 / INLINE_CODE / GOODCASE +Description: JSON file containing Python inline code with simple conditions +Expectation: JsonPreprocessor returns expected values +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2103 / INLINE_CODE / GOODCASE +Description: JSON file containing Python inline code within lists and dictionaries +Expectation: JsonPreprocessor returns expected values +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2105 / INLINE_CODE / GOODCASE +Description: JSON file containing Python inline code in more complex scenarios +Expectation: JsonPreprocessor returns expected values +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2107 / INLINE_CODE / GOODCASE +Description: JSON file containing Python inline code with import paths +Expectation: JsonPreprocessor returns expected values +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2150 / INLINE_CODE / BADCASE +Description: Python inline code as embedded part of a string (1) +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2151 / INLINE_CODE / BADCASE +Description: Python inline code as embedded part of a string (2) +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2152 / INLINE_CODE / BADCASE +Description: Python inline code as embedded part of a string (3) +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2180 / INLINE_CODE / BADCASE +Description: Python inline code with additional leading angle bracket +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2184 / INLINE_CODE / BADCASE +Description: Python inline code inside a dictionary with additional leading angle bracket +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2192 / INLINE_CODE / BADCASE +Description: Python inline code is parameter name +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2193 / INLINE_CODE / BADCASE +Description: Python inline code is parameter name inside a list +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_2194 / INLINE_CODE / BADCASE +Description: Python inline code is parameter name inside a dictionary +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Generated: 11.08.2025 - 16:48:21 diff --git a/test/component_test.py b/test/component_test.py index 1ff943a..a1903a7 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.60.0" -VERSION_DATE = "23.04.2025" +VERSION = "0.66.0" +VERSION_DATE = "13.08.2025" # # -------------------------------------------------------------------------------------------------------------- #TM*** diff --git a/test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py b/test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py new file mode 100644 index 0000000..23901df --- /dev/null +++ b/test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py @@ -0,0 +1,80 @@ +# ************************************************************************************************************** +# Copyright 2020-2023 Robert Bosch GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -------------------------------------------------------------------------------------------------------------- +# +# test_27_INLINE_CODE_GOODCASE.py +# +# XC-HWP/ESW3-Queckenstedt +# +# 11.08.2025 - 16:48:21 +# +# -------------------------------------------------------------------------------------------------------------- + +import pytest +from pytestlibs.CExecute import CExecute + +# -------------------------------------------------------------------------------------------------------------- + +class Test_INLINE_CODE_GOODCASE: + +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected values + @pytest.mark.parametrize( + "Description", ["JSON file containing Python inline code with simple data types",] + ) + def test_JPP_2100(self, Description): + nReturn = CExecute.Execute("JPP_2100") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected values + @pytest.mark.parametrize( + "Description", ["JSON file containing Python inline code with composite data types",] + ) + def test_JPP_2101(self, Description): + nReturn = CExecute.Execute("JPP_2101") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected values + @pytest.mark.parametrize( + "Description", ["JSON file containing Python inline code with simple conditions",] + ) + def test_JPP_2102(self, Description): + nReturn = CExecute.Execute("JPP_2102") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected values + @pytest.mark.parametrize( + "Description", ["JSON file containing Python inline code within lists and dictionaries",] + ) + def test_JPP_2103(self, Description): + nReturn = CExecute.Execute("JPP_2103") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected values + @pytest.mark.parametrize( + "Description", ["JSON file containing Python inline code in more complex scenarios",] + ) + def test_JPP_2105(self, Description): + nReturn = CExecute.Execute("JPP_2105") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected values + @pytest.mark.parametrize( + "Description", ["JSON file containing Python inline code with import paths",] + ) + def test_JPP_2107(self, Description): + nReturn = CExecute.Execute("JPP_2107") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/pytest/pytestfiles/test_28_INLINE_CODE_BADCASE.py b/test/pytest/pytestfiles/test_28_INLINE_CODE_BADCASE.py new file mode 100644 index 0000000..1d32240 --- /dev/null +++ b/test/pytest/pytestfiles/test_28_INLINE_CODE_BADCASE.py @@ -0,0 +1,96 @@ +# ************************************************************************************************************** +# Copyright 2020-2023 Robert Bosch GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -------------------------------------------------------------------------------------------------------------- +# +# test_28_INLINE_CODE_BADCASE.py +# +# XC-HWP/ESW3-Queckenstedt +# +# 11.08.2025 - 16:48:21 +# +# -------------------------------------------------------------------------------------------------------------- + +import pytest +from pytestlibs.CExecute import CExecute + +# -------------------------------------------------------------------------------------------------------------- + +class Test_INLINE_CODE_BADCASE: + +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code as embedded part of a string (1)",] + ) + def test_JPP_2150(self, Description): + nReturn = CExecute.Execute("JPP_2150") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code as embedded part of a string (2)",] + ) + def test_JPP_2151(self, Description): + nReturn = CExecute.Execute("JPP_2151") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code as embedded part of a string (3)",] + ) + def test_JPP_2152(self, Description): + nReturn = CExecute.Execute("JPP_2152") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code with additional leading angle bracket",] + ) + def test_JPP_2180(self, Description): + nReturn = CExecute.Execute("JPP_2180") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code inside a dictionary with additional leading angle bracket",] + ) + def test_JPP_2184(self, Description): + nReturn = CExecute.Execute("JPP_2184") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code is parameter name",] + ) + def test_JPP_2192(self, Description): + nReturn = CExecute.Execute("JPP_2192") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code is parameter name inside a list",] + ) + def test_JPP_2193(self, Description): + nReturn = CExecute.Execute("JPP_2193") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["Python inline code is parameter name inside a dictionary",] + ) + def test_JPP_2194(self, Description): + nReturn = CExecute.Execute("JPP_2194") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 2dd8b59..969fcfc 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -1,6 +1,6 @@ # ************************************************************************************************************** # -# Copyright 2020-2024 Robert Bosch GmbH +# Copyright 2020-2025 Robert Bosch GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 23.04.2025 +# 13.08.2025 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -556,6 +556,20 @@ listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_0006" +dictUsecase['DESCRIPTION'] = "JSON file with Python data types used as key name" +dictUsecase['EXPECTATION'] = "JsonPreprocessor accepts all key names and returns values" +dictUsecase['SECTION'] = "DATA_TYPES" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0006.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None # to be defined +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} dictUsecase['TESTID'] = "JPP_0100" @@ -4425,3 +4439,898 @@ del dictUsecase # -------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2100" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with simple data types" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2100.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (5/1) > {value1} [STR] : 'ABC' +[DOTDICT] (5/2) > {value2} [INT] : 25 +[DOTDICT] (5/3) > {value3} [FLOAT] : 2.5 +[DOTDICT] (5/4) > {value4} [BOOL] : True +[DOTDICT] (5/5) > {value5} [NONE] : None +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2101" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with composite data types" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2101.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (6/1) > {value1} [LIST] (2/1) > [INT] : 1 +[DOTDICT] (6/1) > {value1} [LIST] (2/2) > [INT] : 2 +[DOTDICT] (6/2) > {value2} [DOTDICT] (3/1) > {kA} [INT] : 1 +[DOTDICT] (6/2) > {value2} [DOTDICT] (3/2) > {kB} [INT] : 2 +[DOTDICT] (6/2) > {value2} [DOTDICT] (3/3) > {kC} [INT] : 3 +[DOTDICT] (6/3) > {expression1} [LIST] (2/1) > [INT] : 1 +[DOTDICT] (6/3) > {expression1} [LIST] (2/2) > [INT] : 2 +[DOTDICT] (6/4) > {value3} [LIST] (2/1) > [INT] : 1 +[DOTDICT] (6/4) > {value3} [LIST] (2/2) > [INT] : 2 +[DOTDICT] (6/5) > {expression2} [DOTDICT] (2/1) > {kA} [INT] : 1 +[DOTDICT] (6/5) > {expression2} [DOTDICT] (2/2) > {kB} [INT] : 2 +[DOTDICT] (6/6) > {value4} [DOTDICT] (2/1) > {kA} [INT] : 1 +[DOTDICT] (6/6) > {value4} [DOTDICT] (2/2) > {kB} [INT] : 2 +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2102" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with simple conditions" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2102.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (6/1) > {value1} [INT] : 1 +[DOTDICT] (6/2) > {choice} [BOOL] : True +[DOTDICT] (6/3) > {value2} [INT] : 1 +[DOTDICT] (6/4) > {A} [INT] : 1 +[DOTDICT] (6/5) > {B} [INT] : 2 +[DOTDICT] (6/6) > {value3} [STR] : 'self.JPGlobals['A']' +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2103" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code within lists and dictionaries" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2103.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (4/1) > {A} [INT] : 1 +[DOTDICT] (4/2) > {B} [INT] : 2 +[DOTDICT] (4/3) > {choice} [BOOL] : True +[DOTDICT] (4/4) > {values} [DOTDICT] (3/1) > {kA} [STR] : 'A' +[DOTDICT] (4/4) > {values} [DOTDICT] (3/2) > {kB} [INT] : 1 +[DOTDICT] (4/4) > {values} [DOTDICT] (3/3) > {kC} [STR] : 'C' +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Exception: Expecting ',' delimiter +dictUsecase['TESTID'] = "JPP_2104" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code as list index and dictionary key" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2104.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +""" +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# JSONP file still partially commented out +dictUsecase['TESTID'] = "JPP_2105" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code in more complex scenarios" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2105.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (8/1) > {A} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (8/1) > {A} [LIST] (3/2) > [INT] : 2 +[DOTDICT] (8/1) > {A} [LIST] (3/3) > [INT] : 3 +[DOTDICT] (8/2) > {B} [LIST] (3/1) > [INT] : 4 +[DOTDICT] (8/2) > {B} [LIST] (3/2) > [INT] : 5 +[DOTDICT] (8/2) > {B} [LIST] (3/3) > [INT] : 6 +[DOTDICT] (8/3) > {values} [LIST] (4/1) > [INT] : 1 +[DOTDICT] (8/3) > {values} [LIST] (4/2) > [INT] : 2 +[DOTDICT] (8/3) > {values} [LIST] (4/3) > [INT] : 3 +[DOTDICT] (8/3) > {values} [LIST] (4/4) > [LIST] (6/1) > [INT] : 4 +[DOTDICT] (8/3) > {values} [LIST] (4/4) > [LIST] (6/2) > [INT] : 5 +[DOTDICT] (8/3) > {values} [LIST] (4/4) > [LIST] (6/3) > [INT] : 6 +[DOTDICT] (8/3) > {values} [LIST] (4/4) > [LIST] (6/4) > [INT] : 1 +[DOTDICT] (8/3) > {values} [LIST] (4/4) > [LIST] (6/5) > [INT] : 2 +[DOTDICT] (8/3) > {values} [LIST] (4/4) > [LIST] (6/6) > [INT] : 3 +[DOTDICT] (8/4) > {dict} [DOTDICT] (2/1) > {kA} [STR] : 'vA' +[DOTDICT] (8/4) > {dict} [DOTDICT] (2/2) > {kB} [STR] : 'vB' +[DOTDICT] (8/5) > {key_list} [LIST] (2/1) > [STR] : 'kA' +[DOTDICT] (8/5) > {key_list} [LIST] (2/2) > [STR] : 'kB' +[DOTDICT] (8/6) > {C} [STR] : 'C' +[DOTDICT] (8/7) > {D} [STR] : 'D' +[DOTDICT] (8/8) > {value2} [STR] : 'CD' +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# slicing under discussion +dictUsecase['TESTID'] = "JPP_2106" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with slicing" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2106.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +""" +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2107" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with import paths" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2107.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (3/1) > {path_1} [STR] : './dynamic_imports/AA/imported.AA.jsonp' +[DOTDICT] (3/2) > {path_2} [STR] : './dynamic_imports/AA/BB/imported.BB.jsonp' +[DOTDICT] (3/3) > {level} [STR] : 'AA' +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2108" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code with import of an additional module" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2108.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None # to be defined +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2150" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a string (1)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2150.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Python inline code must not be embedded part of a string" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2151" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a string (2)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2151.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Python inline code must not be embedded part of a string" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2152" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a string (3)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2152.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Python inline code must not be embedded part of a string" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting ',' delimiter +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454 +dictUsecase['TESTID'] = "JPP_2153" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a string within a list" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2153.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# error message to be reworked: Python inline code is not allowed as key! +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2154" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a string within a dictionary" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2154.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2155" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a key name (1)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2155.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2156" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a key name (2)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2156.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2157" +dictUsecase['DESCRIPTION'] = "Python inline code as embedded part of a key name (3)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2157.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2158" +dictUsecase['DESCRIPTION'] = "Python inline code without quotes at left hand side of the colon (1)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2158.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2159" +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['DESCRIPTION'] = "Python inline code without quotes at left hand side of the colon (2)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2159.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2160" +dictUsecase['DESCRIPTION'] = "Python inline code within quotes at left hand side of the colon (1)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2160.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2161" +dictUsecase['DESCRIPTION'] = "Python inline code within quotes at left hand side of the colon (2)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2161.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2162" +dictUsecase['DESCRIPTION'] = "Completely invalid Python inline code at left hand side of the colon (1)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2162.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2163" +dictUsecase['DESCRIPTION'] = "Completely invalid Python inline code at left hand side of the colon (2)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2163.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2164" +dictUsecase['DESCRIPTION'] = "Python inline code as key name at left hand side of the colon (1)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2164.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2165" +dictUsecase['DESCRIPTION'] = "Python inline code as key name at left hand side of the colon (2)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2165.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2166" +dictUsecase['DESCRIPTION'] = "Python inline code as list index at left hand side of the colon" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2166.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Error message "Python inline code is not allowed as key!" should be +# rephrased to "Python inline code cannot be used to define a key name." +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/464 +dictUsecase['TESTID'] = "JPP_2167" +dictUsecase['DESCRIPTION'] = "Python inline code as dictionary key at left hand side of the colon" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2167.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Exception: 'Expecting value: line 2 column 11 +dictUsecase['TESTID'] = "JPP_2168" +dictUsecase['DESCRIPTION'] = "Python inline code with missing leading angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2168.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Exception: 'Expecting value: line 2 column 11 +dictUsecase['TESTID'] = "JPP_2169" +dictUsecase['DESCRIPTION'] = "Python inline code with missing trailing angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2169.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Exception: 'Expecting value: line 2 column 11 +dictUsecase['TESTID'] = "JPP_2170" +dictUsecase['DESCRIPTION'] = "Python inline code inside a list with missing leading angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2170.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Exception: 'Expecting value: line 2 column 11 +dictUsecase['TESTID'] = "JPP_2171" +dictUsecase['DESCRIPTION'] = "Python inline code inside a list with missing trailing angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2171.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Exception: 'Expecting value: line 2 column 11 +dictUsecase['TESTID'] = "JPP_2172" +dictUsecase['DESCRIPTION'] = "Python inline code inside a dictionary with missing leading angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2172.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Exception: 'Expecting value: line 2 column 11 +dictUsecase['TESTID'] = "JPP_2173" +dictUsecase['DESCRIPTION'] = "Python inline code inside a dictionary with missing trailing angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2173.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting ',' delimiter: +dictUsecase['TESTID'] = "JPP_2174" +dictUsecase['DESCRIPTION'] = "Python inline code with missing both leading angle brackets" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2174.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting value: +dictUsecase['TESTID'] = "JPP_2175" +dictUsecase['DESCRIPTION'] = "Python inline code with missing both trailing angle brackets" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2175.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting ',' delimiter +dictUsecase['TESTID'] = "JPP_2176" +dictUsecase['DESCRIPTION'] = "Python inline code inside a list with missing both leading angle brackets" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2176.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting value: +dictUsecase['TESTID'] = "JPP_2177" +dictUsecase['DESCRIPTION'] = "Python inline code inside a list with missing both trailing angle brackets" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2177.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting ',' delimiter +dictUsecase['TESTID'] = "JPP_2178" +dictUsecase['DESCRIPTION'] = "Python inline code inside a dictionary with missing both leading angle brackets" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2178.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting value: +dictUsecase['TESTID'] = "JPP_2179" +dictUsecase['DESCRIPTION'] = "Python inline code inside a dictionary with missing both trailing angle brackets" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2179.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2180" +dictUsecase['DESCRIPTION'] = "Python inline code with additional leading angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2180.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Could not evaluate the Python builtIn" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting ',' delimiter: +dictUsecase['TESTID'] = "JPP_2181" +dictUsecase['DESCRIPTION'] = "Python inline code with additional trailing angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2181.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Python inline code not resolved +dictUsecase['TESTID'] = "JPP_2182" +dictUsecase['DESCRIPTION'] = "Python inline code inside a list with additional leading angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2182.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting ',' delimiter: +dictUsecase['TESTID'] = "JPP_2183" +dictUsecase['DESCRIPTION'] = "Python inline code inside a list with additional trailing angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2183.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2184" +dictUsecase['DESCRIPTION'] = "Python inline code inside a dictionary with additional leading angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2184.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Could not evaluate the Python builtIn" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting ',' delimiter +dictUsecase['TESTID'] = "JPP_2185" +dictUsecase['DESCRIPTION'] = "Python inline code inside a dictionary with additional trailing angle bracket" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2185.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# 'Could not evaluate the Python builtIn <>. +# Reason: invalid syntax (, line 1)' +# Expected: Data type error (not supported by JSON) +dictUsecase['TESTID'] = "JPP_2186" +dictUsecase['DESCRIPTION'] = "Python inline code returns data type not supported by JSON" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2186.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Python inline code not resolved +dictUsecase['TESTID'] = "JPP_2187" +dictUsecase['DESCRIPTION'] = "Python inline code inside a list returns data type not supported by JSON" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2187.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# 'Could not evaluate the Python builtIn <>. +# Reason: invalid syntax (, line 1)' +# Expected: Data type error (not supported by JSON) +dictUsecase['TESTID'] = "JPP_2188" +dictUsecase['DESCRIPTION'] = "Python inline code inside a dictionary returns data type not supported by JSON" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2188.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting value: +# Nesting not detected +dictUsecase['TESTID'] = "JPP_2189" +dictUsecase['DESCRIPTION'] = "Nested Python inline code" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2189.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting value: +# Nesting not detected +dictUsecase['TESTID'] = "JPP_2190" +dictUsecase['DESCRIPTION'] = "Nested Python inline code inside a list" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2190.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +# Expecting value: +# Nesting not detected +dictUsecase['TESTID'] = "JPP_2191" +dictUsecase['DESCRIPTION'] = "Nested Python inline code inside a dictionary" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2191.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2192" +dictUsecase['DESCRIPTION'] = "Python inline code is parameter name" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2192.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Invalid syntax" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2193" +dictUsecase['DESCRIPTION'] = "Python inline code is parameter name inside a list" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2193.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Invalid syntax" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2194" +dictUsecase['DESCRIPTION'] = "Python inline code is parameter name inside a dictionary" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2194.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Invalid syntax" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/testfiles/jpp-test_config_0006.jsonp b/test/testfiles/jpp-test_config_0006.jsonp new file mode 100644 index 0000000..4e5b283 --- /dev/null +++ b/test/testfiles/jpp-test_config_0006.jsonp @@ -0,0 +1,62 @@ +// Copyright 2020-2024 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python data types used as key name + + "int" : [1,2], + ${int}[0] : 3, + + "float" : {"A" : 1, "B" : 2}, + ${float}['A'] : 3, + + "complex" : [1,2], + ${complex}[0] : 3, + + "bool" : {"A" : 1, "B" : 2}, + ${bool}['A'] : 3, + + "str" : [1,2], + ${str}[0] : 3, + + "list" : {"A" : 1, "B" : 2}, + ${list}['A'] : 3, + + "tuple" : [1,2], + ${tuple}[0] : 3, + + "set" : {"A" : 1, "B" : 2}, + ${set}['A'] : 3, + + "frozenset" : [1,2], + ${frozenset}[0] : 3, + + "dict" : {"A" : 1, "B" : 2}, + ${dict}['A'] : 3, + + "NoneType" : [1,2], + ${NoneType}[0] : 3, + + "None" : {"A" : 1, "B" : 2}, + ${None}['A'] : 3, + + "True" : [1,2], + ${True}[0] : 3, + + "False" : {"A" : 1, "B" : 2}, + ${False}['A'] : 3, + + "DotDict" : [1,2], + ${DotDict}[0] : 3 +} diff --git a/test/testfiles/jpp-test_config_2100.jsonp b/test/testfiles/jpp-test_config_2100.jsonp new file mode 100644 index 0000000..4c3604b --- /dev/null +++ b/test/testfiles/jpp-test_config_2100.jsonp @@ -0,0 +1,22 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // simple data types + "value1" : <<"ABC">>, + "value2" : <<25>>, + "value3" : <<2.5>>, + "value4" : <>, + "value5" : <> +} diff --git a/test/testfiles/jpp-test_config_2101.jsonp b/test/testfiles/jpp-test_config_2101.jsonp new file mode 100644 index 0000000..ec684aa --- /dev/null +++ b/test/testfiles/jpp-test_config_2101.jsonp @@ -0,0 +1,23 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Composite data types + "value1" : <<[1, 2]>>, + "value2" : <<{"kA" : 1, "kB" : 2, "kC" : 3}>>, + "expression1" : [1, 2], + "value3" : <<${expression1}>>, + "expression2" : {"kA" : 1, "kB" : 2}, + "value4" : <<${expression2}>> +} diff --git a/test/testfiles/jpp-test_config_2102.jsonp b/test/testfiles/jpp-test_config_2102.jsonp new file mode 100644 index 0000000..dfae545 --- /dev/null +++ b/test/testfiles/jpp-test_config_2102.jsonp @@ -0,0 +1,26 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Simple conditions + // + "value1" : <<1 if True else 2>>, + // + "choice" : True, + "value2" : <<1 if ${choice} else 2>>, + // + "A" : 1, + "B" : 2, + "value3" : <<"${A}" if True else "${B}">> +} diff --git a/test/testfiles/jpp-test_config_2103.jsonp b/test/testfiles/jpp-test_config_2103.jsonp new file mode 100644 index 0000000..6fb669e --- /dev/null +++ b/test/testfiles/jpp-test_config_2103.jsonp @@ -0,0 +1,27 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code within lists and dictionaries + // + "A" : 1, + "B" : 2, + "choice" : True, + // + "values" : ["A", <<${A} if ${choice} else ${B}>>, "C"], + // + "values" : {"kA" : "A", + "kB" : <<${A} if ${choice} else ${B}>>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2104.jsonp b/test/testfiles/jpp-test_config_2104.jsonp new file mode 100644 index 0000000..884f784 --- /dev/null +++ b/test/testfiles/jpp-test_config_2104.jsonp @@ -0,0 +1,28 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as list index and dictionary key + // + "A" : 0, + "B" : 1, + "kA" : "kA", + "kB" : "kB", + // + "listval" : [1,2,3], + "dictval" : {"kA" : "vA", "kB" : "vB"}, + // + "value1" : ${listval}[<<${A} if True else ${B}>>], + "value2" : ${dictval}[<<${kA} if True else ${kB}>>] +} diff --git a/test/testfiles/jpp-test_config_2105.jsonp b/test/testfiles/jpp-test_config_2105.jsonp new file mode 100644 index 0000000..7506511 --- /dev/null +++ b/test/testfiles/jpp-test_config_2105.jsonp @@ -0,0 +1,33 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // More complex scenarios with Python inline code + // + "A" : [1,2,3], + "B" : [4,5,6], + "values" : <<${A} + [${B} + ${A}]>>, + // + "dict" : {"kA" : "vA", "kB" : "vB"}, + "key_list" : <>, + // + // "value1" : <<(${A}[0] if True else ${B.1) + 1>> + // "code1" : (${A}[0] if True else ${B.1) + 1, + // "value1b" : <<(${code04}) + 4>>, + // // + "C" : "C", + "D" : "D", + "value2" : <<${C} + ${D}>> + // "value3" : <<"${C}" + "${D}">> +} diff --git a/test/testfiles/jpp-test_config_2106.jsonp b/test/testfiles/jpp-test_config_2106.jsonp new file mode 100644 index 0000000..f1f7f7f --- /dev/null +++ b/test/testfiles/jpp-test_config_2106.jsonp @@ -0,0 +1,23 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with slicing + "A" : [1,2,3], + "B" : [4,5,6], + "index" : 2, + "values1" : <<${A}[:${index}]>>, + // + "values2" : <<${A} + ${B}[-1]>> +} diff --git a/test/testfiles/jpp-test_config_2107.jsonp b/test/testfiles/jpp-test_config_2107.jsonp new file mode 100644 index 0000000..1ca5ea0 --- /dev/null +++ b/test/testfiles/jpp-test_config_2107.jsonp @@ -0,0 +1,22 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with import paths + // + "path_1" : "./dynamic_imports/AA/imported.AA.jsonp", + "path_2" : "./dynamic_imports/AA/BB/imported.BB.jsonp", + // + "[import]" : <<${path_1} if True else ${path_2}>> +} diff --git a/test/testfiles/jpp-test_config_2108.jsonp b/test/testfiles/jpp-test_config_2108.jsonp new file mode 100644 index 0000000..bc765e6 --- /dev/null +++ b/test/testfiles/jpp-test_config_2108.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with import of an additional module + // + "element" : <> +} diff --git a/test/testfiles/jpp-test_config_2150.jsonp b/test/testfiles/jpp-test_config_2150.jsonp new file mode 100644 index 0000000..d8ac02a --- /dev/null +++ b/test/testfiles/jpp-test_config_2150.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a string (1) + // + "value" : "<<[1, 2]>>" +} diff --git a/test/testfiles/jpp-test_config_2151.jsonp b/test/testfiles/jpp-test_config_2151.jsonp new file mode 100644 index 0000000..97b6aa7 --- /dev/null +++ b/test/testfiles/jpp-test_config_2151.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a string (2) + // + "value" : "ABC <<[\"A\", \"B\"]>> DEF" +} diff --git a/test/testfiles/jpp-test_config_2152.jsonp b/test/testfiles/jpp-test_config_2152.jsonp new file mode 100644 index 0000000..d48b168 --- /dev/null +++ b/test/testfiles/jpp-test_config_2152.jsonp @@ -0,0 +1,20 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a string (3) + // + "A" : [1,2,3], + "value" : "ABC <<${A}>> DEF" +} diff --git a/test/testfiles/jpp-test_config_2153.jsonp b/test/testfiles/jpp-test_config_2153.jsonp new file mode 100644 index 0000000..37bdf5b --- /dev/null +++ b/test/testfiles/jpp-test_config_2153.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a string within a list + // + "value" : ["ABC", "<<[1, 2]>>", "DEF"] +} diff --git a/test/testfiles/jpp-test_config_2154.jsonp b/test/testfiles/jpp-test_config_2154.jsonp new file mode 100644 index 0000000..83ed50c --- /dev/null +++ b/test/testfiles/jpp-test_config_2154.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a string within a dictionary + // + "value" : {"A" : 1, "B" : "<<[1, 2]>>", "C" : 1} +} diff --git a/test/testfiles/jpp-test_config_2155.jsonp b/test/testfiles/jpp-test_config_2155.jsonp new file mode 100644 index 0000000..a078675 --- /dev/null +++ b/test/testfiles/jpp-test_config_2155.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a key name (1) + // + "<<[1, 2]>>" : 1 +} diff --git a/test/testfiles/jpp-test_config_2156.jsonp b/test/testfiles/jpp-test_config_2156.jsonp new file mode 100644 index 0000000..6c3d3d8 --- /dev/null +++ b/test/testfiles/jpp-test_config_2156.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a key name (2) + // + "ABC <<[\"A\", \"B\"]>> DEF" : 1 +} diff --git a/test/testfiles/jpp-test_config_2157.jsonp b/test/testfiles/jpp-test_config_2157.jsonp new file mode 100644 index 0000000..28b8fb9 --- /dev/null +++ b/test/testfiles/jpp-test_config_2157.jsonp @@ -0,0 +1,20 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as embedded part of a key name (3) + // + "A" : [1,2,3], + "<<${A}>>" : 1 +} diff --git a/test/testfiles/jpp-test_config_2158.jsonp b/test/testfiles/jpp-test_config_2158.jsonp new file mode 100644 index 0000000..eb19a58 --- /dev/null +++ b/test/testfiles/jpp-test_config_2158.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code without quotes at left hand side of the colon (1) + // + <<1 if True else 2>> : 1 +} diff --git a/test/testfiles/jpp-test_config_2159.jsonp b/test/testfiles/jpp-test_config_2159.jsonp new file mode 100644 index 0000000..1e5c61c --- /dev/null +++ b/test/testfiles/jpp-test_config_2159.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code without quotes at left hand side of the colon (2) + // + <<"A" if True else "B">> : 1 +} diff --git a/test/testfiles/jpp-test_config_2160.jsonp b/test/testfiles/jpp-test_config_2160.jsonp new file mode 100644 index 0000000..2d14ace --- /dev/null +++ b/test/testfiles/jpp-test_config_2160.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code within quotes at left hand side of the colon (1) + // + "<<1 if True else 2>>" : 1 +} diff --git a/test/testfiles/jpp-test_config_2161.jsonp b/test/testfiles/jpp-test_config_2161.jsonp new file mode 100644 index 0000000..175df97 --- /dev/null +++ b/test/testfiles/jpp-test_config_2161.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code within quotes at left hand side of the colon (2) + // + "<<(\"A\" if True else \"B\">>" : 1 +} diff --git a/test/testfiles/jpp-test_config_2162.jsonp b/test/testfiles/jpp-test_config_2162.jsonp new file mode 100644 index 0000000..e43ee7d --- /dev/null +++ b/test/testfiles/jpp-test_config_2162.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Completely invalid Python inline code at left hand side of the colon (1) + // + "A"_<<1 if True else 2>> : "B" +} diff --git a/test/testfiles/jpp-test_config_2163.jsonp b/test/testfiles/jpp-test_config_2163.jsonp new file mode 100644 index 0000000..bf0d5f7 --- /dev/null +++ b/test/testfiles/jpp-test_config_2163.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Completely invalid Python inline code at left hand side of the colon (2) + // + <<1 if True else 2>>_"A" : "B" +} diff --git a/test/testfiles/jpp-test_config_2164.jsonp b/test/testfiles/jpp-test_config_2164.jsonp new file mode 100644 index 0000000..4a649f1 --- /dev/null +++ b/test/testfiles/jpp-test_config_2164.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as key name at left hand side of the colon (1) + // + ${<<1 if True else 2>>} : "B" +} diff --git a/test/testfiles/jpp-test_config_2165.jsonp b/test/testfiles/jpp-test_config_2165.jsonp new file mode 100644 index 0000000..8c72bc7 --- /dev/null +++ b/test/testfiles/jpp-test_config_2165.jsonp @@ -0,0 +1,20 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as key name at left hand side of the colon (2) + // + "A" : [1,2,3], + ${<<1 if ${A} else 2>>} : "B" +} diff --git a/test/testfiles/jpp-test_config_2166.jsonp b/test/testfiles/jpp-test_config_2166.jsonp new file mode 100644 index 0000000..1c5ca28 --- /dev/null +++ b/test/testfiles/jpp-test_config_2166.jsonp @@ -0,0 +1,20 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as list index at left hand side of the colon + // + "A" : [1,2,3], + ${A}[<<0 if True else 1>>] : 4 +} diff --git a/test/testfiles/jpp-test_config_2167.jsonp b/test/testfiles/jpp-test_config_2167.jsonp new file mode 100644 index 0000000..0d96620 --- /dev/null +++ b/test/testfiles/jpp-test_config_2167.jsonp @@ -0,0 +1,20 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code as dictionary key at left hand side of the colon + // + "A" : {"B" : 1, "C" : 2}, + ${A}[<<"B" if True else "C">>] : 3 +} diff --git a/test/testfiles/jpp-test_config_2168.jsonp b/test/testfiles/jpp-test_config_2168.jsonp new file mode 100644 index 0000000..c424097 --- /dev/null +++ b/test/testfiles/jpp-test_config_2168.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with missing leading angle bracket + // + "A" : <0 if True else 1>> +} diff --git a/test/testfiles/jpp-test_config_2169.jsonp b/test/testfiles/jpp-test_config_2169.jsonp new file mode 100644 index 0000000..f7d7276 --- /dev/null +++ b/test/testfiles/jpp-test_config_2169.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with missing trailing angle bracket + // + "A" : <<0 if True else 1> +} diff --git a/test/testfiles/jpp-test_config_2170.jsonp b/test/testfiles/jpp-test_config_2170.jsonp new file mode 100644 index 0000000..6e37566 --- /dev/null +++ b/test/testfiles/jpp-test_config_2170.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a list with missing leading angle bracket + // + "A" : ["B", <1 if True else 2>>, "C"] +} diff --git a/test/testfiles/jpp-test_config_2171.jsonp b/test/testfiles/jpp-test_config_2171.jsonp new file mode 100644 index 0000000..f214276 --- /dev/null +++ b/test/testfiles/jpp-test_config_2171.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a list with missing trailing angle bracket + // + "A" : ["B", <<1 if True else 2>, "C"] +} diff --git a/test/testfiles/jpp-test_config_2172.jsonp b/test/testfiles/jpp-test_config_2172.jsonp new file mode 100644 index 0000000..478d9d0 --- /dev/null +++ b/test/testfiles/jpp-test_config_2172.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a dictionary with missing leading angle bracket + // + "A" : {"kA" : "A", + "kB" : <1 if True else 2>>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2173.jsonp b/test/testfiles/jpp-test_config_2173.jsonp new file mode 100644 index 0000000..15d9860 --- /dev/null +++ b/test/testfiles/jpp-test_config_2173.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a dictionary with missing trailing angle bracket + // + "A" : {"kA" : "A", + "kB" : <<1 if True else 2>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2174.jsonp b/test/testfiles/jpp-test_config_2174.jsonp new file mode 100644 index 0000000..20ff1c7 --- /dev/null +++ b/test/testfiles/jpp-test_config_2174.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with missing both leading angle brackets + // + "A" : 0 if True else 1>> +} diff --git a/test/testfiles/jpp-test_config_2175.jsonp b/test/testfiles/jpp-test_config_2175.jsonp new file mode 100644 index 0000000..ff907ca --- /dev/null +++ b/test/testfiles/jpp-test_config_2175.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with missing both trailing angle brackets + // + "A" : <<0 if True else 1 +} diff --git a/test/testfiles/jpp-test_config_2176.jsonp b/test/testfiles/jpp-test_config_2176.jsonp new file mode 100644 index 0000000..9ee6932 --- /dev/null +++ b/test/testfiles/jpp-test_config_2176.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a list with missing both leading angle brackets + // + "A" : ["B", 1 if True else 2>>, "C"] +} diff --git a/test/testfiles/jpp-test_config_2177.jsonp b/test/testfiles/jpp-test_config_2177.jsonp new file mode 100644 index 0000000..76dc1ad --- /dev/null +++ b/test/testfiles/jpp-test_config_2177.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a list with missing both trailing angle brackets + // + "A" : ["B", <<1 if True else 2, "C"] +} diff --git a/test/testfiles/jpp-test_config_2178.jsonp b/test/testfiles/jpp-test_config_2178.jsonp new file mode 100644 index 0000000..19baf5e --- /dev/null +++ b/test/testfiles/jpp-test_config_2178.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a dictionary with missing both leading angle brackets + // + "A" : {"kA" : "A", + "kB" : 1 if True else 2>>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2179.jsonp b/test/testfiles/jpp-test_config_2179.jsonp new file mode 100644 index 0000000..2c771fa --- /dev/null +++ b/test/testfiles/jpp-test_config_2179.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a dictionary with missing both trailing angle brackets + // + "A" : {"kA" : "A", + "kB" : <<1 if True else 2, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2180.jsonp b/test/testfiles/jpp-test_config_2180.jsonp new file mode 100644 index 0000000..1e4d25c --- /dev/null +++ b/test/testfiles/jpp-test_config_2180.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with additional leading angle bracket + // + "A" : <<<0 if True else 1>> +} diff --git a/test/testfiles/jpp-test_config_2181.jsonp b/test/testfiles/jpp-test_config_2181.jsonp new file mode 100644 index 0000000..2865fc3 --- /dev/null +++ b/test/testfiles/jpp-test_config_2181.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code with additional trailing angle bracket + // + "A" : <<0 if True else 1>>> +} diff --git a/test/testfiles/jpp-test_config_2182.jsonp b/test/testfiles/jpp-test_config_2182.jsonp new file mode 100644 index 0000000..6ab2910 --- /dev/null +++ b/test/testfiles/jpp-test_config_2182.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a list with additional leading angle bracket + // + "A" : ["B", <<<1 if True else 2>>, "C"] +} diff --git a/test/testfiles/jpp-test_config_2183.jsonp b/test/testfiles/jpp-test_config_2183.jsonp new file mode 100644 index 0000000..9576227 --- /dev/null +++ b/test/testfiles/jpp-test_config_2183.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a list with additional trailing angle bracket + // + "A" : ["B", <<1 if True else 2>>>, "C"] +} diff --git a/test/testfiles/jpp-test_config_2184.jsonp b/test/testfiles/jpp-test_config_2184.jsonp new file mode 100644 index 0000000..b9c0ebc --- /dev/null +++ b/test/testfiles/jpp-test_config_2184.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a dictionary with additional leading angle bracket + // + "A" : {"kA" : "A", + "kB" : <<<1 if True else 2>>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2185.jsonp b/test/testfiles/jpp-test_config_2185.jsonp new file mode 100644 index 0000000..f573542 --- /dev/null +++ b/test/testfiles/jpp-test_config_2185.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a dictionary with additional trailing angle bracket + // + "A" : {"kA" : "A", + "kB" : <<1 if True else 2>>>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2186.jsonp b/test/testfiles/jpp-test_config_2186.jsonp new file mode 100644 index 0000000..f599c89 --- /dev/null +++ b/test/testfiles/jpp-test_config_2186.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code returns data type not supported by JSON + // + "now" : <> +} diff --git a/test/testfiles/jpp-test_config_2187.jsonp b/test/testfiles/jpp-test_config_2187.jsonp new file mode 100644 index 0000000..7474f92 --- /dev/null +++ b/test/testfiles/jpp-test_config_2187.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a list returns data type not supported by JSON + // + "A" : ["B", <>, "C"] +} diff --git a/test/testfiles/jpp-test_config_2188.jsonp b/test/testfiles/jpp-test_config_2188.jsonp new file mode 100644 index 0000000..2527571 --- /dev/null +++ b/test/testfiles/jpp-test_config_2188.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code inside a dictionary returns data type not supported by JSON + // + "A" : {"kA" : "A", + "now" : <>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2189.jsonp b/test/testfiles/jpp-test_config_2189.jsonp new file mode 100644 index 0000000..0bef138 --- /dev/null +++ b/test/testfiles/jpp-test_config_2189.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Nested Python inline code + // + "value" : <<[1, 2] + <<[3, 4] if True else [5, 6]>>>> +} diff --git a/test/testfiles/jpp-test_config_2190.jsonp b/test/testfiles/jpp-test_config_2190.jsonp new file mode 100644 index 0000000..fe2d3c7 --- /dev/null +++ b/test/testfiles/jpp-test_config_2190.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Nested Python inline code inside a list + // + "A" : ["B", <<[1, 2] + <<[3, 4] if True else [5, 6]>>>>, "C"] +} diff --git a/test/testfiles/jpp-test_config_2191.jsonp b/test/testfiles/jpp-test_config_2191.jsonp new file mode 100644 index 0000000..060fe55 --- /dev/null +++ b/test/testfiles/jpp-test_config_2191.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Nested Python inline code inside a dictionary + // + "A" : {"kA" : "A", + "kB" : <<[1, 2] + <<[3, 4] if True else [5, 6]>>>>, + "kC" : "C"} +} diff --git a/test/testfiles/jpp-test_config_2192.jsonp b/test/testfiles/jpp-test_config_2192.jsonp new file mode 100644 index 0000000..10738de --- /dev/null +++ b/test/testfiles/jpp-test_config_2192.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code is parameter name + // + "value" : ${<<[3, 4] if True else [5, 6]>>} +} diff --git a/test/testfiles/jpp-test_config_2193.jsonp b/test/testfiles/jpp-test_config_2193.jsonp new file mode 100644 index 0000000..6a2811d --- /dev/null +++ b/test/testfiles/jpp-test_config_2193.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code is parameter name inside a list + // + "A" : ["B", ${<<[3, 4] if True else [5, 6]>>}, "C"] +} diff --git a/test/testfiles/jpp-test_config_2194.jsonp b/test/testfiles/jpp-test_config_2194.jsonp new file mode 100644 index 0000000..4df4294 --- /dev/null +++ b/test/testfiles/jpp-test_config_2194.jsonp @@ -0,0 +1,21 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//************************************************************************** +{ + // Python inline code is parameter name inside a dictionary + // + "A" : {"kA" : "A", + "kB" : ${<<[3, 4] if True else [5, 6]>>}, + "kC" : "C"} +} diff --git a/test/testtools/GenSnippetsJPP.py b/test/testtools/GenSnippetsJPP.py index 4d74a40..ad4ad75 100644 --- a/test/testtools/GenSnippetsJPP.py +++ b/test/testtools/GenSnippetsJPP.py @@ -22,8 +22,8 @@ # # ************************************************************************************************************** # -VERSION = "0.38.0" -VERSION_DATE = "10.01.2025" +VERSION = "0.47.0" +VERSION_DATE = "13.08.2025" # # ************************************************************************************************************** @@ -3440,6 +3440,572 @@ def GetSeveralParticularSnippets(self): } """) + # -------------------------------------------------------------------------------------------------------------- + + # -- unicode digits + + listCodeSnippets.append("""{ + "listparam_൯" : [1,2,3,4,5,6,7,8,9,10], + "listvalue" : ${listparam_൯}[൯] +} +""") + + # -------------------------------------------------------------------------------------------------------------- + # -- Python inline code + # -------------------------------------------------------------------------------------------------------------- + + # -- TODO: GOODCASE (snippets to be taken over from selftest) + + listCodeSnippets.append("""{ + // Python inline code with import of an additional module + "element" : <> +} +""") + + # -- BADCASE (from official selftest) + + listCodeSnippets.append("""{ + // "JPP_2150" + // Python inline code as embedded part of a string (1) + "value" : "<<[1, 2]>>" +} +""") + + listCodeSnippets.append("""{ + // "JPP_2151" + // Python inline code as embedded part of a string (2) + "value" : "ABC <<[\"A\", \"B\"]>> DEF" +} +""") + + listCodeSnippets.append("""{ + // "JPP_2152" + // Python inline code as embedded part of a string (3) + "A" : [1,2,3], + "value" : "ABC <<${A}>> DEF" +} +""") + + listCodeSnippets.append("""{ + // "JPP_2153" + // Python inline code as embedded part of a string within a list + "value" : ["ABC", "<<[1, 2]>>", "DEF"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2154" + // Python inline code as embedded part of a string within a dictionary + "value" : {"A" : 1, "B" : "<<[1, 2]>>", "C" : 1} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2155" + // Python inline code as embedded part of a key name (1) + "<<[1, 2]>>" : 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2156" + // Python inline code as embedded part of a key name (2) + "ABC <<[\"A\", \"B\"]>> DEF" : 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2157" + // Python inline code as embedded part of a key name (3) + "A" : [1,2,3], + "<<${A}>>" : 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2158" + // Python inline code without quotes at left hand side of the colon (1) + <<1 if True else 2>> : 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2159" + // Python inline code without quotes at left hand side of the colon (2) + <<"A" if True else "B">> : 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2160" + // Python inline code within quotes at left hand side of the colon (1) + "<<1 if True else 2>>" : 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2161" + // Python inline code within quotes at left hand side of the colon (2) + "<<(\"A\" if True else \"B\">>" : 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2162" + // Completely invalid Python inline code at left hand side of the colon (1) + "A"_<<1 if True else 2>> : "B" +} +""") + + listCodeSnippets.append("""{ + // "JPP_2163" + // Completely invalid Python inline code at left hand side of the colon (2) + <<1 if True else 2>>_"A" : "B" +} +""") + + listCodeSnippets.append("""{ + // "JPP_2164" + // Python inline code as key name at left hand side of the colon (1) + ${<<1 if True else 2>>} : "B" +} +""") + + listCodeSnippets.append("""{ + // "JPP_2165" + // Python inline code as key name at left hand side of the colon (2) + "A" : [1,2,3], + ${<<1 if ${A} else 2>>} : "B" +} +""") + + listCodeSnippets.append("""{ + // "JPP_2166" + // Python inline code as list index at left hand side of the colon + "A" : [1,2,3], + ${A}[<<0 if True else 1>>] : 4 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2167" + // Python inline code as dictionary key at left hand side of the colon + "A" : {"B" : 1, "C" . 2}, + ${A}[<<"B" if True else "C">>] : 3 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2168" + // Python inline code with missing leading angle bracket + "A" : <0 if True else 1>> +} +""") + + listCodeSnippets.append("""{ + // "JPP_2169" + // Python inline code with missing trailing angle bracket + "A" : <<0 if True else 1> +} +""") + + listCodeSnippets.append("""{ + // "JPP_2170" + // Python inline code inside a list with missing leading angle bracket + "A" : ["B", <1 if True else 2>>, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2171" + // Python inline code inside a list with missing trailing angle bracket + "A" : ["B", <<1 if True else 2>, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2172" + // Python inline code inside a dictionary with missing leading angle bracket + "A" : {"kA" : "A", + "kB" : <1 if True else 2>>, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2173" + // Python inline code inside a dictionary with missing trailing angle bracket + "A" : {"kA" : "A", + "kB" : <<1 if True else 2>, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2174" + // Python inline code with missing both leading angle brackets + "A" : 0 if True else 1>> +} +""") + + listCodeSnippets.append("""{ + // "JPP_2175" + // Python inline code with missing both trailing angle brackets + "A" : <<0 if True else 1 +} +""") + + listCodeSnippets.append("""{ + // "JPP_2176" + // Python inline code inside a list with missing both leading angle brackets + "A" : ["B", 1 if True else 2>>, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2177" + // Python inline code inside a list with missing both trailing angle brackets + "A" : ["B", <<1 if True else 2, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2178" + // Python inline code inside a dictionary with missing both leading angle brackets + "A" : {"kA" : "A", + "kB" : 1 if True else 2>>, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2179" + // Python inline code inside a dictionary with missing both trailing angle brackets + "A" : {"kA" : "A", + "kB" : <<1 if True else 2, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2180" + // Python inline code with additional leading angle bracket + "A" : <<<0 if True else 1>> +} +""") + + listCodeSnippets.append("""{ + // "JPP_2181" + // Python inline code with additional trailing angle bracket + "A" : <<0 if True else 1>>> +} +""") + + listCodeSnippets.append("""{ + // "JPP_2182" + // Python inline code inside a list with additional leading angle bracket + "A" : ["B", <<<1 if True else 2>>, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2183" + // Python inline code inside a list with additional trailing angle bracket + "A" : ["B", <<1 if True else 2>>>, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2184" + // Python inline code inside a dictionary with additional leading angle bracket + "A" : {"kA" : "A", + "kB" : <<<1 if True else 2>>, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2185" + // Python inline code inside a dictionary with additional trailing angle bracket + "A" : {"kA" : "A", + "kB" : <<1 if True else 2>>>, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2186" + // Python inline code returns data type not supported by JSON + "now" : <> +} +""") + + listCodeSnippets.append("""{ + // "JPP_2187" + // Python inline code inside a list returns data type not supported by JSON + "A" : ["B", <>, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2188" + // Python inline code inside a dictionary returns data type not supported by JSON + "A" : {"kA" : "A", + "now" : <>, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2189" + // Nested Python inline code + "value" : <<[1, 2] + <<[3, 4] if True else [5, 6]>>>> +} +""") + + listCodeSnippets.append("""{ + // "JPP_2190" + // Nested Python inline code inside a list + "A" : ["B", <<[1, 2] + <<[3, 4] if True else [5, 6]>>>>, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2191" + // Nested Python inline code inside a dictionary + "A" : {"kA" : "A", + "kB" : <<[1, 2] + <<[3, 4] if True else [5, 6]>>>>, + "kC" : "C"} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2192" + // Python inline code is parameter name + "value" : ${<<[3, 4] if True else [5, 6]>>} +} +""") + + listCodeSnippets.append("""{ + // "JPP_2193" + // Python inline code is parameter name inside a list + "A" : ["B", ${<<[3, 4] if True else [5, 6]>>}, "C"] +} +""") + + listCodeSnippets.append("""{ + // "JPP_2194" + // Python inline code is parameter name inside a dictionary + "A" : {"kA" : "A", + "kB" : ${<<[3, 4] if True else [5, 6]>>}, + "kC" : "C"} +} +""") + + + + # -- Python inline code - old stuff (to be shortened) + + listCodeSnippets.append("""{ + "A" : 1, + "B" : 2, + "choice" : True, + "value" : <<${A} if ${choice} else ${B}>> +} +""") + + listCodeSnippets.append("""{ + "A" : 1, + "B" : 4, + "choice" : True, + "value_1" : <<(${A} if ${choice} else ${B}) + 4>>, + "code_1" : "${A} if ${choice} else ${B}", + "value_1b" : <<(${code_1}) + 4>>, + "value_2" : <<(${A} if not ${choice} else ${B}) + 4>>, + "code_2" : "${A} if not ${choice} else ${B}", + "value_2b" : <<(${code_2}) + 4>> +} +""") + + listCodeSnippets.append("""{ + "value" : <<25>> +} +""") + + listCodeSnippets.append("""{ + "value" : <<[1, 2]>> +} +""") + + listCodeSnippets.append("""{ + "value" : <<{"kA" : 1, "kB" : 2, "kC" : 3}>> +} +""") + + listCodeSnippets.append("""{ + "A" : 1, + "B" : 2, + "choice" : True, + "values" : ["A", <<${A} if ${choice} else ${B}>>, "Z"] +} +""") + + listCodeSnippets.append("""{ + "A" : 1, + "B" : 2, + "choice" : True, + "values" : {"kA" : "A", + "kB" : <<${A} if ${choice} else ${B}>>, + "kC" : "Z"} +} +""") + + listCodeSnippets.append("""{ + "A" : [1,2,3], + "B" : [4,5,6], + "values" : <<${A} + [${B} + ${A}]>> +} +""") + + + listCodeSnippets.append("""{ + "value" : <<1 if True else 2>> +} +""") + + listCodeSnippets.append("""{ + "choice" : True, + "value" : "<<1 if ${choice} else 2>>" +} +""") + + listCodeSnippets.append("""{ + "A" : [1,2,3], + "B" : [4,5,6], + "values" : <<${A} + <<${A} + ${B}>> >> +} +""") + + listCodeSnippets.append("""{ + "value"_<<1 if True else 2>> : 25 +} +""") + + listCodeSnippets.append("""{ + "value_<<1 if True else 2>>" : 25 +} +""") + + listCodeSnippets.append("""{ + "choice" : True, + "value"_<<1 if ${choice} else 2>> : 25 +} +""") + + listCodeSnippets.append("""{ + "code" : "1 if True else 2", + "value" : <<${code>> +} +""") + + listCodeSnippets.append("""{ + "code" : "1 if True else 2", + "value" : <<${code}> +} +""") + + listCodeSnippets.append("""{ + "code" : "1 if True else 2", + "value" : > +} +""") + + listCodeSnippets.append("""{ + "A" : 0, + "B" : 1, + "C" : [2,3,4], + "value" : ${C}[<<${A} if True else ${B}>>] +} +""") + + listCodeSnippets.append("""{ + "A" : 0, + "B" : 1, + "C" : [2,3,4], + "value" : ${C}[<<"${A}" if True else "${B}">>] +} +""") + + listCodeSnippets.append("""{ + "A" : "kA", + "B" : "kB", + "C" : {"kA" : "vA", "kB" : "vB"}, + "value" : ${C}[<<${A} if True else ${B}>>] +} +""") + + listCodeSnippets.append("""{ + "A" : "kA", + "B" : "kB", + "C" : {"kA" : "vA", "kB" : "vB"}, + "value" : ${C}[<<"${A}" if True else "${B}">>] +} +""") + + listCodeSnippets.append("""{ + "path_1" : "./imports/AA/imported.AA.jsonp", + "path_2" : "./imports/AA/imported.X.jsonp", + "[import]" : <<${path_1} if True else ${path_2}>> +} +""") + + listCodeSnippets.append("""{ + "A" : <<1 + B>> +} +""") + + listCodeSnippets.append("""{ + "C" : <<1 + ${D}>> +} +""") + + listCodeSnippets.append("""{ + "D" : <<1 / 0>> +} +""") + + listCodeSnippets.append("""{ + "E" : 0, + "F" : <<1 / ${E}>> +} +""") + + listCodeSnippets.append("""{ + "G" : {"a" : 0, "b" : 1}, + "H" : <<1 / ${G}['a']>> +} +""") + + listCodeSnippets.append("""{ + "K" : [0,1], + "L" : <<1 / ${K}[0]>> +} +""") + + listCodeSnippets.append("""{ + "dict" : {"kA" : "vA", "kB" : "vB"}, + "key_list" : <> +} +""") + + + # listCodeSnippets.append("""{ +# } +# """) + + + # -------------------------------------------------------------------------------------------------------------- + # listCodeSnippets.append("""{ # } # """) @@ -3865,7 +4431,7 @@ def GetNotExistingParams(self): # -------------------------------------------------------------------------------------------------------------- - def GetKeywords(self): + def GetPythonKeywordsAtSeveralPositions(self): """Python keywords at several positions within a complex data structure """ @@ -3936,15 +4502,82 @@ def GetKeywords(self): return sHeadline, listCodeSnippets - # eof def GetKeywords(self): + # eof def GetPythonKeywordsAtSeveralPositions(self): + + # -------------------------------------------------------------------------------------------------------------- + + def GetPythonKeywordsUsedAsKeyName(self): + + """Python keywords used as key name + """ + + sHeadline = "Python keywords used as key name" + + # data structure + sDataStructurePattern = """ "##01##" : [1,2], + ${##01##}[0] : 3, + // + "##02##" : {"A" : 1, "B" : 2}, + ${##02##}['A'] : 3""" + + sCodeSnippetPattern = """{ +####DATASTRUCTURE#### +} +""" + + # We have a list of expressions and we have a list of placeholders like used in sDataStructure. + # The followig code runs in a nested loop: Every expression is placed at every placeholder position. Only one single + # expression and placeholder per iteration. All remaining placeholders in current iteration are replaced by elements + # from a list of filler expressions (simple values) that are only used to complete the code snippet, + # but are not in focus. + + listExpressions = ["int", "float", "complex", "bool", "str", "list", "tuple", "set", "frozenset", "dict", "NoneType", + "None", "True", "False", "DotDict", + "dev", "class", "self", "return", "import", "[import]"] + + nNrOfPlaceholders = 2 + + listPlaceholders = [] + listFillers = [] + for number in range(1, nNrOfPlaceholders+1): + value1 = str(number).rjust(2, "0") + listPlaceholders.append(f"##{value1}##") + value2 = str(number).rjust(3, "0") + listFillers.append(f"key_{value2}") + + listPositions = listPlaceholders[:] # to support a nested iterations of the same list (better readibility of code because of different names) + + # -- put all things together + listCodeSnippets = [] + for sExpression in listExpressions: + for sPosition in listPositions: + sDataStructure = sDataStructurePattern # init a new data structure from data structure pattern + sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern + oFiller = CListElements(listFillers) # init a new filler object (= content for remaining placeholders) + for sPlaceholder in listPlaceholders: + sFiller = oFiller.GetElement() + if sPosition == sPlaceholder: + sDataStructure = sDataStructure.replace(sPlaceholder, sExpression) + else: + # sDataStructure = sDataStructure.replace(sPlaceholder, f"\"{sFiller}\"") + sDataStructure = sDataStructure.replace(sPlaceholder, f"{sFiller}") + # eof for sPlaceholder in listPlaceholders: + sCodeSnippet = sCodeSnippet.replace("####DATASTRUCTURE####", sDataStructure) + listCodeSnippets.append(sCodeSnippet) + # eof for sPosition in listPositions: + # eof for sExpression in listExpressions: + + return sHeadline, listCodeSnippets + + # eof def GetPythonKeywordsUsedAsKeyName(self): # -------------------------------------------------------------------------------------------------------------- - def GetMissingBrackets(self): - """Missing brackets at several positions within a complex data structure + def GetMissingBrackets_1(self): + """Missing brackets at several positions within a complex data structure (1) """ - sHeadline = "Missing brackets at several positions within a complex data structure" + sHeadline = "Missing brackets at several positions within a complex data structure (1)" # data structure 1 sDataStructure1 = """ "params" : {*01* : *02*, @@ -4012,7 +4645,129 @@ def GetMissingBrackets(self): return sHeadline, listCodeSnippets - # eof def GetMissingBrackets(self): + # eof def GetMissingBrackets_1(self): + + # -------------------------------------------------------------------------------------------------------------- + + def GetMissingBrackets_2(self): + """Missing brackets at several positions within a complex data structure (2) + """ + + sHeadline = "Missing brackets at several positions within a complex data structure (2)" + + JSONP = """ "A" : 1, "B" : 2, "C" : 3, "D" : 4, "E" : 5, "F" : 6, "G" : 7, "H" : 8, "I" : 9, "J" : 10, + "params" : [ + 11, + {"A" : 12, + "B" : [ + { + "C" : 13, + ${params}[1]['B'][0]['C'] : 130, + "D" : 14, + ${params.1.B.0.D} : 140, + "E" : 15, + "F" : 16, + "G" : ["017", {"018" : "019"}], + "H" : [{"020" : "021"}, "022"], + "I" : {"023" : ["024", "025"]}, + "J" : {"026" : ["027", {"028" : ["029", "030"]}]} + }, + 31 + ] + }, + 32 + ], + ${params}[1]['B'][0]['E'] : 150, + ${params.1.B.0.F} : 160, + ${params}[1]['B'][0]['J']['026'][1]['028'][0] : "0290", + ${params.1.B.0.J.026.1.028.1} : "0300" """ + + sCodeSnippetPattern = """{ +####DATASTRUCTURE#### +} +""" + + # prepare the data structure pattern (automatically out of JSONP) + sDataStructurePattern = "" + + curly_open = "{" + curly_close = "}" + square_open = "[" + square_close = "]" + + list_placeholder_curly_open = [] + list_placeholder_curly_close = [] + list_placeholder_square_open = [] + list_placeholder_square_close = [] + + cnt_brackets = 0 + + for char in JSONP: + if char == curly_open: + cnt_brackets = cnt_brackets + 1 + numberstring = str(cnt_brackets).rjust(2, "0") + placeholder = f"##{numberstring}##" + sDataStructurePattern = sDataStructurePattern + placeholder + list_placeholder_curly_open.append(placeholder) + elif char == curly_close: + cnt_brackets = cnt_brackets + 1 + numberstring = str(cnt_brackets).rjust(2, "0") + placeholder = f"##{numberstring}##" + sDataStructurePattern = sDataStructurePattern + placeholder + list_placeholder_curly_close.append(placeholder) + elif char == square_open: + cnt_brackets = cnt_brackets + 1 + numberstring = str(cnt_brackets).rjust(2, "0") + placeholder = f"##{numberstring}##" + sDataStructurePattern = sDataStructurePattern + placeholder + list_placeholder_square_open.append(placeholder) + elif char == square_close: + cnt_brackets = cnt_brackets + 1 + numberstring = str(cnt_brackets).rjust(2, "0") + placeholder = f"##{numberstring}##" + sDataStructurePattern = sDataStructurePattern + placeholder + list_placeholder_square_close.append(placeholder) + else: + sDataStructurePattern = sDataStructurePattern + char + + nNrOfPlaceholders = len(list_placeholder_curly_open) + \ + len(list_placeholder_curly_close) + \ + len(list_placeholder_square_open) + \ + len(list_placeholder_square_close) + + # prepare list of code snippets + + listCodeSnippets = [] + + for number_1 in range(1, nNrOfPlaceholders+1): + numberstring_1 = str(number_1).rjust(2, "0") + placeholder_1 = f"##{numberstring_1}##" + sDataStructure = sDataStructurePattern # init a new data structure from pattern sDataStructurePattern + sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern + # remove the bracket at current position + sDataStructure = sDataStructure.replace(placeholder_1, "") + for number_2 in range(1, nNrOfPlaceholders+1): + numberstring_2 = str(number_2).rjust(2, "0") + placeholder_2 = f"##{numberstring_2}##" + if placeholder_2 in list_placeholder_curly_open: + replacement = curly_open + elif placeholder_2 in list_placeholder_curly_close: + replacement = curly_close + elif placeholder_2 in list_placeholder_square_open: + replacement = square_open + elif placeholder_2 in list_placeholder_square_close: + replacement = square_close + else: + replacement = "" # should not happen + sDataStructure = sDataStructure.replace(placeholder_2, replacement) + # eof for number_2 in range(1, nNrOfPlaceholders+1): + sCodeSnippet = sCodeSnippet.replace("####DATASTRUCTURE####", sDataStructure) + listCodeSnippets.append(sCodeSnippet) + # eof for number_1 in range(1, nNrOfPlaceholders+1): + + return sHeadline, listCodeSnippets + + # eof def GetMissingBrackets_2(self): # -------------------------------------------------------------------------------------------------------------- @@ -4533,7 +5288,7 @@ def GetInternalTokenStrings(self): # from a list of filler expressions (simple letters) that are only used to complete the code snippet, but are not in focus. listExpressions = ["__handleColonsInLine__","__handleDuplicatedKey__00","__handleDuplicatedKey__","__ConvertParameterToString__", - "__IndexOfList__","__SlicingIndex__","__StringValueMake-up__"] + "__IndexOfList__","__SlicingIndex__","__StringValueMake-up__","JPavoidDataType_"] listPlaceholders = ["*01*",] @@ -4571,6 +5326,101 @@ def GetInternalTokenStrings(self): # -------------------------------------------------------------------------------------------------------------- + def GetInlineCode(self): + """Python inline code at several positions within a complex data structure + """ + + sHeadline = "Python inline code at several positions within a complex data structure" + + # scheme: + # "EvT" : 1000, + # "EvF" : 2000, + # # # "EvT" : "EVAL_TRUE", + # # # "EvF" : "EVAL_FALSE", + # "choice" : True, + # "value_1" : <<..>>, + # "value_2" : [10, <<..>>, 11], + # "value_3" : [20, <<..>>, <<..>>, 22], + # "value_4" : [<<..>>, 30, <<..>>], + # "value_5" : {"kA" : 40, "kB" : <<..>>, "kC" : 41}, + # "value_6" : {"kD" : <<..>>, "kE" : <<..>>}, + # "value_7" : {"kF" : [<<..>>, 60], "kG" : [80, <<..>>]}, + # "value_8" : [{"kH" : [<<..>>, 60]}, {"kM" : {"kN" : [70, <<..>>]}}] + + # data structure + sDataStructurePattern = """ "value_1" : ##01##, + "value_2" : [10, ##02##, 11], + "value_3" : [20, ##03##, ##04##, 22], + "value_4" : [##05##, 30, ##06##], + "value_5" : {"kA" : 40, "kB" : ##07##, "kC" : 41}, + "value_6" : {"kD" : ##08##, "kE" : ##09##}, + "value_7" : {"kF" : [##10##, 60], "kG" : [80, ##11##]}, + "value_8" : [{"kH" : [##12##, 60]}, {"kM" : {"kN" : [70, ##13##]}}]""" + + sDefinitions = """ "EvT" : 1000, + "EvF" : 2000, + "choice" : True,""" + # sDefinitions = """ "EvT" : "EVAL_TRUE", + # "EvF" : "EVAL_FALSE", + # "choice" : True,""" + + sCodeSnippetPattern = """{ +####DEFINITIONS#### +####DATASTRUCTURE#### +} +""" + + # We have a list of expressions and we have a list of placeholders like used in sDataStructure. + # The followig code runs in a nested loop: Every expression is placed at every placeholder position. Only one single + # expression and placeholder per iteration. All remaining placeholders in current iteration are replaced by elements + # from a list of filler expressions (simple values) that are only used to complete the code snippet, + # but are not in focus. + + listExpressions = ["<<${EvT} if ${choice} else ${EvF}>>", "${<<[3, 4] if True else [5, 6]>>}"] + # listExpressions = ["<<\"${EvT}\" if ${choice} else \"${EvF}\">>",] + + nNrOfPlaceholders = 13 + + listPlaceholders = [] + listFillers = [] + for number in range(1, nNrOfPlaceholders+1): + value1 = str(number).rjust(2, "0") + listPlaceholders.append(f"##{value1}##") + value2 = str(number).rjust(3, "0") + listFillers.append(f"{value2}") + + listPositions = listPlaceholders[:] # to support a nested iterations of the same list (better readibility of code because of different names) + + # -- put all things together + listCodeSnippets = [] + for sExpression in listExpressions: + for sPosition in listPositions: + sDataStructure = sDataStructurePattern # init a new data structure from data structure pattern + sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern + oFiller = CListElements(listFillers) # init a new filler object (= content for remaining placeholders) + for sPlaceholder in listPlaceholders: + sFiller = oFiller.GetElement() + if sPosition == sPlaceholder: + sDataStructure = sDataStructure.replace(sPlaceholder, sExpression) + else: + sDataStructure = sDataStructure.replace(sPlaceholder, f"\"{sFiller}\"") + # eof for sPlaceholder in listPlaceholders: + sCodeSnippet = sCodeSnippet.replace("####DEFINITIONS####", sDefinitions) + sCodeSnippet = sCodeSnippet.replace("####DATASTRUCTURE####", sDataStructure) + listCodeSnippets.append(sCodeSnippet) + # eof for sPosition in listPositions: + # eof for sExpression in listExpressions: + +# TODO: Add bad cases / invalid syntax +# TODO: merge of lists +# TODO: indices and dictionary keys by eval + + return sHeadline, listCodeSnippets + + # eof def GetInlineCode(self): + + # -------------------------------------------------------------------------------------------------------------- + # eof class CSnippets(): # -------------------------------------------------------------------------------------------------------------- @@ -4694,10 +5544,16 @@ def GetInternalTokenStrings(self): sHeadline, listCodeSnippets = oSnippets.GetNotExistingParams() bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") -sHeadline, listCodeSnippets = oSnippets.GetKeywords() +sHeadline, listCodeSnippets = oSnippets.GetPythonKeywordsAtSeveralPositions() +bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") + +sHeadline, listCodeSnippets = oSnippets.GetPythonKeywordsUsedAsKeyName() bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") -sHeadline, listCodeSnippets = oSnippets.GetMissingBrackets() +sHeadline, listCodeSnippets = oSnippets.GetMissingBrackets_1() +bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") + +sHeadline, listCodeSnippets = oSnippets.GetMissingBrackets_2() bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") sHeadline, listCodeSnippets = oSnippets.GetAdditionalBrackets() @@ -4721,6 +5577,9 @@ def GetInternalTokenStrings(self): sHeadline, listCodeSnippets = oSnippets.GetInternalTokenStrings() bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") +sHeadline, listCodeSnippets = oSnippets.GetInlineCode() +bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") + print() print(COLBG + "done") print()