diff --git a/JsonPreprocessor/JsonPreprocessor.pdf b/JsonPreprocessor/JsonPreprocessor.pdf index b4d74cd..e793535 100644 Binary files a/JsonPreprocessor/JsonPreprocessor.pdf and b/JsonPreprocessor/JsonPreprocessor.pdf differ diff --git a/packagedoc/additional_docs/The JSONP format.tex b/packagedoc/additional_docs/The JSONP format.tex index 5b4ccc9..021df5f 100644 --- a/packagedoc/additional_docs/The JSONP format.tex +++ b/packagedoc/additional_docs/The JSONP format.tex @@ -158,10 +158,11 @@ \section{Naming convention} All key names in JSONP files must adhere to the following rules: \begin{itemize} - \item Key names can only consist of letters, digits and the following special characters: \pcode{_ + - * / \\} + \item Key names can only consist of letters, digits and the following special characters: \pcode{_ + - * / \\\\ @} (\textit{backslashes are allowed but have to be masked}). \item Key names have to start with a letter, a digit or an underscore. \item Key names must not be empty strings. But leading and trailing blanks will be removed (and therefore do not cause errors). + Also blanks in between allowed characters are not allowed. \end{itemize} % -------------------------------------------------------------------------------------------------------------- diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index e9caa37..081a64c 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -2291,7 +2291,7 @@ JSON file with several invalid parameter names (1)
-Expected: All names are accepted (in definition and in reference) +Expected: Expected: No values are returned, and JsonPreprocessor throws an exception
@@ -2324,7 +2324,7 @@ JSON file with several invalid parameter names (2)
-Expected: All names are accepted (in definition and in reference) +Expected: Expected: No values are returned, and JsonPreprocessor throws an exception
@@ -2357,7 +2357,7 @@ JSON file with several invalid parameter names (3)
-Expected: All names are accepted (in definition and in reference) +Expected: Expected: No values are returned, and JsonPreprocessor throws an exception
@@ -2390,7 +2390,7 @@ JSON file with several invalid parameter names (4)
-Expected: All names are accepted (in definition and in reference) +Expected: Expected: No values are returned, and JsonPreprocessor throws an exception
@@ -2423,7 +2423,7 @@ JSON file with several invalid parameter names (5)
-Expected: All names are accepted (in definition and in reference) +Expected: Expected: No values are returned, and JsonPreprocessor throws an exception
@@ -2456,7 +2456,7 @@ JSON file with several invalid parameter names (6)
-Expected: All names are accepted (in definition and in reference) +Expected: Expected: No values are returned, and JsonPreprocessor throws an exception
@@ -6742,7 +6742,7 @@
 

-
Generated: 03.01.2025 - 16:19:20
+
Generated: 09.01.2025 - 18:56:30
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index 49f7a09..4c4763e 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -745,7 +745,7 @@ Test Use Cases **JSON file with several invalid parameter names (1)** - Expected: All names are accepted (in definition and in reference) + Expected: Expected: No values are returned, and JsonPreprocessor throws an exception ---- @@ -755,7 +755,7 @@ Test Use Cases **JSON file with several invalid parameter names (2)** - Expected: All names are accepted (in definition and in reference) + Expected: Expected: No values are returned, and JsonPreprocessor throws an exception ---- @@ -765,7 +765,7 @@ Test Use Cases **JSON file with several invalid parameter names (3)** - Expected: All names are accepted (in definition and in reference) + Expected: Expected: No values are returned, and JsonPreprocessor throws an exception ---- @@ -775,7 +775,7 @@ Test Use Cases **JSON file with several invalid parameter names (4)** - Expected: All names are accepted (in definition and in reference) + Expected: Expected: No values are returned, and JsonPreprocessor throws an exception ---- @@ -785,7 +785,7 @@ Test Use Cases **JSON file with several invalid parameter names (5)** - Expected: All names are accepted (in definition and in reference) + Expected: Expected: No values are returned, and JsonPreprocessor throws an exception ---- @@ -795,7 +795,7 @@ Test Use Cases **JSON file with several invalid parameter names (6)** - Expected: All names are accepted (in definition and in reference) + Expected: Expected: No values are returned, and JsonPreprocessor throws an exception ---- @@ -2125,5 +2125,5 @@ Test Use Cases ---- -Generated: 03.01.2025 - 16:19:20 +Generated: 09.01.2025 - 18:56:30 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index e61f7f5..5886a31 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -312,27 +312,27 @@ Expectation: All names are accepted (in definition and in reference) ------------------------------------------------------------------------------------------------------------------------ Test JPP_0450 / NAMING_CONVENTION / BADCASE Description: JSON file with several invalid parameter names (1) -Expectation: All names are accepted (in definition and in reference) +Expectation: Expected: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ Test JPP_0451 / NAMING_CONVENTION / BADCASE Description: JSON file with several invalid parameter names (2) -Expectation: All names are accepted (in definition and in reference) +Expectation: Expected: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ Test JPP_0452 / NAMING_CONVENTION / BADCASE Description: JSON file with several invalid parameter names (3) -Expectation: All names are accepted (in definition and in reference) +Expectation: Expected: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ Test JPP_0453 / NAMING_CONVENTION / BADCASE Description: JSON file with several invalid parameter names (4) -Expectation: All names are accepted (in definition and in reference) +Expectation: Expected: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ Test JPP_0454 / NAMING_CONVENTION / BADCASE Description: JSON file with several invalid parameter names (5) -Expectation: All names are accepted (in definition and in reference) +Expectation: Expected: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ Test JPP_0455 / NAMING_CONVENTION / BADCASE Description: JSON file with several invalid parameter names (6) -Expectation: All names are accepted (in definition and in reference) +Expectation: Expected: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ Test JPP_0500 / COMPOSITE_EXPRESSIONS / GOODCASE Description: JSON file with composite data structure (nested lists and dictionaries 1) @@ -868,5 +868,5 @@ 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: 03.01.2025 - 16:19:20 +Generated: 09.01.2025 - 18:56:30 diff --git a/test/component_test.py b/test/component_test.py index 92d1b7b..1d89408 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.56.0" -VERSION_DATE = "03.01.2025" +VERSION = "0.57.0" +VERSION_DATE = "09.01.2025" # # -------------------------------------------------------------------------------------------------------------- #TM*** diff --git a/test/pytest/pytestfiles/test_08_NAMING_CONVENTION_BADCASE.py b/test/pytest/pytestfiles/test_08_NAMING_CONVENTION_BADCASE.py index 7b3484b..87eddff 100644 --- a/test/pytest/pytestfiles/test_08_NAMING_CONVENTION_BADCASE.py +++ b/test/pytest/pytestfiles/test_08_NAMING_CONVENTION_BADCASE.py @@ -18,7 +18,7 @@ # # XC-HWP/ESW3-Queckenstedt # -# 28.10.2024 - 20:15:13 +# 09.01.2025 - 18:56:30 # # -------------------------------------------------------------------------------------------------------------- @@ -30,7 +30,7 @@ class Test_NAMING_CONVENTION_BADCASE: # -------------------------------------------------------------------------------------------------------------- - # Expected: All names are accepted (in definition and in reference) + # Expected: Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( "Description", ["JSON file with several invalid parameter names (1)",] ) @@ -38,7 +38,7 @@ def test_JPP_0450(self, Description): nReturn = CExecute.Execute("JPP_0450") assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- - # Expected: All names are accepted (in definition and in reference) + # Expected: Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( "Description", ["JSON file with several invalid parameter names (2)",] ) @@ -46,7 +46,7 @@ def test_JPP_0451(self, Description): nReturn = CExecute.Execute("JPP_0451") assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- - # Expected: All names are accepted (in definition and in reference) + # Expected: Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( "Description", ["JSON file with several invalid parameter names (3)",] ) @@ -54,7 +54,7 @@ def test_JPP_0452(self, Description): nReturn = CExecute.Execute("JPP_0452") assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- - # Expected: All names are accepted (in definition and in reference) + # Expected: Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( "Description", ["JSON file with several invalid parameter names (4)",] ) @@ -62,7 +62,7 @@ def test_JPP_0453(self, Description): nReturn = CExecute.Execute("JPP_0453") assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- - # Expected: All names are accepted (in definition and in reference) + # Expected: Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( "Description", ["JSON file with several invalid parameter names (5)",] ) @@ -70,7 +70,7 @@ def test_JPP_0454(self, Description): nReturn = CExecute.Execute("JPP_0454") assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- - # Expected: All names are accepted (in definition and in reference) + # Expected: Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( "Description", ["JSON file with several invalid parameter names (6)",] ) diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 5555c8f..ea81551 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 03.01.2025 +# 09.01.2025 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -1618,6 +1618,9 @@ # -------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} +# https://github.com/test-fullautomation/python-jsonpreprocessor/issues/406 +# 'invalid group reference 5 at position 9'! +# partially commented out dictUsecase['TESTID'] = "JPP_0400" dictUsecase['DESCRIPTION'] = "JSON file with several parameter names w.r.t. the naming convention" dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" @@ -1628,81 +1631,116 @@ dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0400.jsonp" dictUsecase['EXPECTEDEXCEPTION'] = None dictUsecase['EXPECTEDRETURN'] = """ -[DOTDICT] (55/1) > {A} [INT] : 1 -[DOTDICT] (55/2) > {check01} [INT] : 1 -[DOTDICT] (55/3) > {_} [INT] : 3 -[DOTDICT] (55/4) > {check03} [INT] : 3 -[DOTDICT] (55/5) > {Ax} [INT] : 4 -[DOTDICT] (55/6) > {check04} [INT] : 4 -[DOTDICT] (55/7) > {0x} [INT] : 5 -[DOTDICT] (55/8) > {check05} [INT] : 5 -[DOTDICT] (55/9) > {_x} [INT] : 6 -[DOTDICT] (55/10) > {check06} [INT] : 6 -[DOTDICT] (55/11) > {param+1} [INT] : 7 -[DOTDICT] (55/12) > {check07} [INT] : 7 -[DOTDICT] (55/13) > {param-2} [INT] : 8 -[DOTDICT] (55/14) > {check08} [INT] : 8 -[DOTDICT] (55/15) > {param*3} [INT] : 9 -[DOTDICT] (55/16) > {check09} [INT] : 9 -[DOTDICT] (55/17) > {param/4} [INT] : 10 -[DOTDICT] (55/18) > {p01} [DOTDICT] (1/1) > {A} [INT] : 7 -[DOTDICT] (55/19) > {check11} [INT] : 7 -[DOTDICT] (55/20) > {p02} [DOTDICT] (1/1) > {0} [INT] : 8 -[DOTDICT] (55/21) > {check12} [INT] : 8 -[DOTDICT] (55/22) > {p03} [DOTDICT] (1/1) > {_} [INT] : 9 -[DOTDICT] (55/23) > {check13} [INT] : 9 -[DOTDICT] (55/24) > {p04} [DOTDICT] (1/1) > {Ax} [INT] : 10 -[DOTDICT] (55/25) > {check14} [INT] : 10 -[DOTDICT] (55/26) > {p05} [DOTDICT] (1/1) > {0x} [INT] : 11 -[DOTDICT] (55/27) > {check15} [INT] : 11 -[DOTDICT] (55/28) > {p06} [DOTDICT] (1/1) > {_x} [INT] : 12 -[DOTDICT] (55/29) > {check16} [INT] : 12 -[DOTDICT] (55/30) > {p07} [DOTDICT] (1/1) > {param+1} [INT] : 13 -[DOTDICT] (55/31) > {check17} [INT] : 13 -[DOTDICT] (55/32) > {p08} [DOTDICT] (1/1) > {param-2} [INT] : 14 -[DOTDICT] (55/33) > {check18} [INT] : 14 -[DOTDICT] (55/34) > {p09} [DOTDICT] (1/1) > {param*3} [INT] : 15 -[DOTDICT] (55/35) > {check19} [INT] : 15 -[DOTDICT] (55/36) > {p10} [DOTDICT] (1/1) > {param/4} [INT] : 16 -[DOTDICT] (55/37) > {p11} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/37) > {p11} [LIST] (3/2) > [DOTDICT] (1/1) > {A} [INT] : 17 -[DOTDICT] (55/37) > {p11} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/38) > {check21} [INT] : 17 -[DOTDICT] (55/39) > {p12} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/39) > {p12} [LIST] (3/2) > [DOTDICT] (1/1) > {0} [INT] : 18 -[DOTDICT] (55/39) > {p12} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/40) > {check22} [INT] : 18 -[DOTDICT] (55/41) > {p13} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/41) > {p13} [LIST] (3/2) > [DOTDICT] (1/1) > {_} [INT] : 19 -[DOTDICT] (55/41) > {p13} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/42) > {check23} [INT] : 19 -[DOTDICT] (55/43) > {p14} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/43) > {p14} [LIST] (3/2) > [DOTDICT] (1/1) > {Ax} [INT] : 20 -[DOTDICT] (55/43) > {p14} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/44) > {check24} [INT] : 20 -[DOTDICT] (55/45) > {p15} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/45) > {p15} [LIST] (3/2) > [DOTDICT] (1/1) > {0x} [INT] : 21 -[DOTDICT] (55/45) > {p15} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/46) > {check25} [INT] : 21 -[DOTDICT] (55/47) > {p16} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/47) > {p16} [LIST] (3/2) > [DOTDICT] (1/1) > {_x} [INT] : 22 -[DOTDICT] (55/47) > {p16} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/48) > {check26} [INT] : 22 -[DOTDICT] (55/49) > {p17} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/49) > {p17} [LIST] (3/2) > [DOTDICT] (1/1) > {param+1} [INT] : 23 -[DOTDICT] (55/49) > {p17} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/50) > {check27} [INT] : 23 -[DOTDICT] (55/51) > {p18} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/51) > {p18} [LIST] (3/2) > [DOTDICT] (1/1) > {param-2} [INT] : 24 -[DOTDICT] (55/51) > {p18} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/52) > {check28} [INT] : 24 -[DOTDICT] (55/53) > {p19} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/53) > {p19} [LIST] (3/2) > [DOTDICT] (1/1) > {param*3} [INT] : 25 -[DOTDICT] (55/53) > {p19} [LIST] (3/3) > [INT] : 2 -[DOTDICT] (55/54) > {check29} [INT] : 25 -[DOTDICT] (55/55) > {p20} [LIST] (3/1) > [INT] : 1 -[DOTDICT] (55/55) > {p20} [LIST] (3/2) > [DOTDICT] (1/1) > {param/4} [INT] : 26 -[DOTDICT] (55/55) > {p20} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/1) > {A} [INT] : 1 +[DOTDICT] (86/2) > {check01} [INT] : 1 +[DOTDICT] (86/3) > {0} [INT] : 2 +[DOTDICT] (86/4) > {check02} [INT] : 2 +[DOTDICT] (86/5) > {_} [INT] : 3 +[DOTDICT] (86/6) > {check03} [INT] : 3 +[DOTDICT] (86/7) > {Ax} [INT] : 4 +[DOTDICT] (86/8) > {check04} [INT] : 4 +[DOTDICT] (86/9) > {0x} [INT] : 5 +[DOTDICT] (86/10) > {check05} [INT] : 5 +[DOTDICT] (86/11) > {_x} [INT] : 6 +[DOTDICT] (86/12) > {check06} [INT] : 6 +[DOTDICT] (86/13) > {param+1} [INT] : 7 +[DOTDICT] (86/14) > {check07} [INT] : 7 +[DOTDICT] (86/15) > {param-2} [INT] : 8 +[DOTDICT] (86/16) > {check08} [INT] : 8 +[DOTDICT] (86/17) > {param*3} [INT] : 9 +[DOTDICT] (86/18) > {check09} [INT] : 9 +[DOTDICT] (86/19) > {param/4} [INT] : 10 +[DOTDICT] (86/20) > {check10} [INT] : 10 +[DOTDICT] (86/21) > {p01} [DOTDICT] (1/1) > {A} [INT] : 7 +[DOTDICT] (86/22) > {check11} [INT] : 7 +[DOTDICT] (86/23) > {check12} [INT] : 7 +[DOTDICT] (86/24) > {p02} [DOTDICT] (1/1) > {0} [INT] : 8 +[DOTDICT] (86/25) > {check13} [INT] : 8 +[DOTDICT] (86/26) > {check14} [INT] : 8 +[DOTDICT] (86/27) > {p03} [DOTDICT] (1/1) > {_} [INT] : 9 +[DOTDICT] (86/28) > {check15} [INT] : 9 +[DOTDICT] (86/29) > {check16} [INT] : 9 +[DOTDICT] (86/30) > {p04} [DOTDICT] (1/1) > {Ax} [INT] : 10 +[DOTDICT] (86/31) > {check17} [INT] : 10 +[DOTDICT] (86/32) > {check18} [INT] : 10 +[DOTDICT] (86/33) > {p05} [DOTDICT] (1/1) > {0x} [INT] : 11 +[DOTDICT] (86/34) > {check19} [INT] : 11 +[DOTDICT] (86/35) > {check20} [INT] : 11 +[DOTDICT] (86/36) > {p06} [DOTDICT] (1/1) > {_x} [INT] : 12 +[DOTDICT] (86/37) > {check21} [INT] : 12 +[DOTDICT] (86/38) > {check22} [INT] : 12 +[DOTDICT] (86/39) > {p07} [DOTDICT] (1/1) > {param+1} [INT] : 13 +[DOTDICT] (86/40) > {check23} [INT] : 13 +[DOTDICT] (86/41) > {check24} [INT] : 13 +[DOTDICT] (86/42) > {p08} [DOTDICT] (1/1) > {param-2} [INT] : 14 +[DOTDICT] (86/43) > {check25} [INT] : 14 +[DOTDICT] (86/44) > {check26} [INT] : 14 +[DOTDICT] (86/45) > {p09} [DOTDICT] (1/1) > {param*3} [INT] : 15 +[DOTDICT] (86/46) > {check27} [INT] : 15 +[DOTDICT] (86/47) > {check28} [INT] : 15 +[DOTDICT] (86/48) > {p10} [DOTDICT] (1/1) > {param/4} [INT] : 16 +[DOTDICT] (86/49) > {check29} [INT] : 16 +[DOTDICT] (86/50) > {check30} [INT] : 16 +[DOTDICT] (86/51) > {p11} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/51) > {p11} [LIST] (3/2) > [DOTDICT] (1/1) > {A} [INT] : 17 +[DOTDICT] (86/51) > {p11} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/52) > {check31} [INT] : 17 +[DOTDICT] (86/53) > {check32} [INT] : 17 +[DOTDICT] (86/54) > {p12} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/54) > {p12} [LIST] (3/2) > [DOTDICT] (1/1) > {0} [INT] : 18 +[DOTDICT] (86/54) > {p12} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/55) > {check33} [INT] : 18 +[DOTDICT] (86/56) > {check34} [INT] : 18 +[DOTDICT] (86/57) > {p13} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/57) > {p13} [LIST] (3/2) > [DOTDICT] (1/1) > {_} [INT] : 19 +[DOTDICT] (86/57) > {p13} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/58) > {check35} [INT] : 19 +[DOTDICT] (86/59) > {check36} [INT] : 19 +[DOTDICT] (86/60) > {p14} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/60) > {p14} [LIST] (3/2) > [DOTDICT] (1/1) > {Ax} [INT] : 20 +[DOTDICT] (86/60) > {p14} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/61) > {check37} [INT] : 20 +[DOTDICT] (86/62) > {check38} [INT] : 20 +[DOTDICT] (86/63) > {p15} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/63) > {p15} [LIST] (3/2) > [DOTDICT] (1/1) > {0x} [INT] : 21 +[DOTDICT] (86/63) > {p15} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/64) > {check39} [INT] : 21 +[DOTDICT] (86/65) > {check40} [INT] : 21 +[DOTDICT] (86/66) > {p16} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/66) > {p16} [LIST] (3/2) > [DOTDICT] (1/1) > {_x} [INT] : 22 +[DOTDICT] (86/66) > {p16} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/67) > {check41} [INT] : 22 +[DOTDICT] (86/68) > {check42} [INT] : 22 +[DOTDICT] (86/69) > {p+17} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/69) > {p+17} [LIST] (3/2) > [DOTDICT] (1/1) > {param+1} [INT] : 23 +[DOTDICT] (86/69) > {p+17} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/70) > {check43} [INT] : 23 +[DOTDICT] (86/71) > {check44} [INT] : 23 +[DOTDICT] (86/72) > {p-18} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/72) > {p-18} [LIST] (3/2) > [DOTDICT] (1/1) > {param-2} [INT] : 24 +[DOTDICT] (86/72) > {p-18} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/73) > {check45} [INT] : 24 +[DOTDICT] (86/74) > {check46} [INT] : 24 +[DOTDICT] (86/75) > {p*19} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/75) > {p*19} [LIST] (3/2) > [DOTDICT] (1/1) > {param*3} [INT] : 25 +[DOTDICT] (86/75) > {p*19} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/76) > {check47} [INT] : 25 +[DOTDICT] (86/77) > {check48} [INT] : 25 +[DOTDICT] (86/78) > {p/20} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/78) > {p/20} [LIST] (3/2) > [DOTDICT] (1/1) > {param/4} [INT] : 26 +[DOTDICT] (86/78) > {p/20} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/79) > {check49} [INT] : 26 +[DOTDICT] (86/80) > {check50} [INT] : 26 +[DOTDICT] (86/81) > {p@22} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/81) > {p@22} [LIST] (3/2) > [DOTDICT] (1/1) > {param@6} [INT] : 28 +[DOTDICT] (86/81) > {p@22} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/82) > {check53} [INT] : 28 +[DOTDICT] (86/83) > {check54} [INT] : 28 +[DOTDICT] (86/84) > {p23} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (86/84) > {p23} [LIST] (3/2) > [DOTDICT] (1/1) > {param7} [INT] : 28 +[DOTDICT] (86/84) > {p23} [LIST] (3/3) > [INT] : 2 +[DOTDICT] (86/85) > {check55} [INT] : 28 +[DOTDICT] (86/86) > {check56} [INT] : 28 """ listofdictUsecases.append(dictUsecase) del dictUsecase @@ -1726,7 +1764,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0450" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (1)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1740,7 +1778,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0451" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (2)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1754,7 +1792,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0452" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (3)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1768,7 +1806,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0453" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (4)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1782,7 +1820,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0454" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (5)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1796,7 +1834,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0455" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (6)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1810,7 +1848,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0456" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (7)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1824,7 +1862,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0457" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (8)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1838,7 +1876,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0458" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (9)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1852,7 +1890,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0459" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (10)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1866,7 +1904,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0460" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (11)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1880,7 +1918,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0461" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (12)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1894,7 +1932,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0462" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (13)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1908,7 +1946,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0463" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (14)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1922,7 +1960,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0464" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (15)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1936,7 +1974,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0465" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (16)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None @@ -1950,7 +1988,7 @@ dictUsecase = {} dictUsecase['TESTID'] = "JPP_0466" dictUsecase['DESCRIPTION'] = "JSON file with several invalid parameter names (17)" -dictUsecase['EXPECTATION'] = "All names are accepted (in definition and in reference)" +dictUsecase['EXPECTATION'] = "Expected: No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "NAMING_CONVENTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = None diff --git a/test/testfiles/jpp-test_config_0400.jsonp b/test/testfiles/jpp-test_config_0400.jsonp index 4b4d79e..60ae540 100644 --- a/test/testfiles/jpp-test_config_0400.jsonp +++ b/test/testfiles/jpp-test_config_0400.jsonp @@ -15,10 +15,8 @@ { "A" : 1, "check01" : ${A}, - // Bug: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/357#issuecomment-2435677836 - // 'The parameter '${0}' is not available!'! - // "0" : 2, - // "check02" : ${0}, + "0" : 2, + "check02" : ${0}, "_" : 3, "check03" : ${_}, // @@ -36,55 +34,84 @@ "param*3" : 9, "check09" : ${param*3}, "param/4" : 10, - // bug: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/356#issuecomment-2435708593 - // Expecting ',' delimiter - // "check10" : ${param/4}, + "check10" : ${param/4}, // - "p01" : {"A" : 7}, + "p01" : {"A" : 7}, "check11" : ${p01}['A'], - "p02" : {"0" : 8}, - "check12" : ${p02}['0'], - "p03" : {"_" : 9}, - "check13" : ${p03}['_'], + "check12" : ${p01.A}, + "p02" : {"0" : 8}, + "check13" : ${p02}['0'], + "check14" : ${p02.0}, + "p03" : {"_" : 9}, + "check15" : ${p03}['_'], + "check16" : ${p03._}, // - "p04" : {"Ax" : 10}, - "check14" : ${p04}['Ax'], - "p05" : {"0x" : 11}, - "check15" : ${p05}['0x'], - "p06" : {"_x" : 12}, - "check16" : ${p06}['_x'], + "p04" : {"Ax" : 10}, + "check17" : ${p04}['Ax'], + "check18" : ${p04.Ax}, + "p05" : {"0x" : 11}, + "check19" : ${p05}['0x'], + "check20" : ${p05.0x}, + "p06" : {"_x" : 12}, + "check21" : ${p06}['_x'], + "check22" : ${p06._x}, + + "p07" : {"param+1" : 13}, + "check23" : ${p07}['param+1'], + "check24" : ${p07.param+1}, + "p08" : {"param-2" : 14}, + "check25" : ${p08}['param-2'], + "check26" : ${p08.param-2}, + "p09" : {"param*3" : 15}, + "check27" : ${p09}['param*3'], + "check28" : ${p09.param*3}, + "p10" : {"param/4" : 16}, + "check29" : ${p10}['param/4'], + "check30" : ${p10.param/4}, // - "p07" : {"param+1" : 13}, - "check17" : ${p07}['param+1'], - "p08" : {"param-2" : 14}, - "check18" : ${p08}['param-2'], - "p09" : {"param*3" : 15}, - "check19" : ${p09}['param*3'], - "p10" : {"param/4" : 16}, - // Expecting ',' delimiter - // "check20" : ${p10}['param/4'], + "p11" : [1, {"A" : 17}, 2], + "check31" : ${p11}[1]['A'], + "check32" : ${p11.1.A}, + "p12" : [1, {"0" : 18}, 2], + "check33" : ${p12}[1]['0'], + "check34" : ${p12.1.0}, + "p13" : [1, {"_" : 19}, 2], + "check35" : ${p13}[1]['_'], + "check36" : ${p13.1._}, // - "p11" : [1, {"A" : 17}, 2], - "check21" : ${p11}[1]['A'], - "p12" : [1, {"0" : 18}, 2], - "check22" : ${p12}[1]['0'], - "p13" : [1, {"_" : 19}, 2], - "check23" : ${p13}[1]['_'], + "p14" : [1, {"Ax" : 20}, 2], + "check37" : ${p14}[1]['Ax'], + "check38" : ${p14.1.Ax}, + "p15" : [1, {"0x" : 21}, 2], + "check39" : ${p15}[1]['0x'], + "check40" : ${p15.1.0x}, + "p16" : [1, {"_x" : 22}, 2], + "check41" : ${p16}[1]['_x'], + "check42" : ${p16.1._x}, // - "p14" : [1, {"Ax" : 20}, 2], - "check24" : ${p14}[1]['Ax'], - "p15" : [1, {"0x" : 21}, 2], - "check25" : ${p15}[1]['0x'], - "p16" : [1, {"_x" : 22}, 2], - "check26" : ${p16}[1]['_x'], - // // - "p17" : [1, {"param+1" : 23}, 2], - "check27" : ${p17}[1]['param+1'], - "p18" : [1, {"param-2" : 24}, 2], - "check28" : ${p18}[1]['param-2'], - "p19" : [1, {"param*3" : 25}, 2], - "check29" : ${p19}[1]['param*3'], - "p20" : [1, {"param/4" : 26}, 2] - // Expecting ',' delimiter - // "check30" : ${p20}[1]['param/4'] + "p+17" : [1, {"param+1" : 23}, 2], + "check43" : ${p+17}[1]['param+1'], + "check44" : ${p+17.1.param+1}, + "p-18" : [1, {"param-2" : 24}, 2], + "check45" : ${p-18}[1]['param-2'], + "check46" : ${p-18.1.param-2}, + "p*19" : [1, {"param*3" : 25}, 2], + "check47" : ${p*19}[1]['param*3'], + "check48" : ${p*19.1.param*3}, + "p/20" : [1, {"param/4" : 26}, 2], + "check49" : ${p/20}[1]['param/4'], + "check50" : ${p/20.1.param/4}, + + // https://github.com/test-fullautomation/python-jsonpreprocessor/issues/406 + // 'invalid group reference 5 at position 9'! + // "p\\21" : [1, {"param\\5" : 27}, 2] + // "check51" : ${p\\21}[1]['param\\5'], + // "check52" : ${p\\21.1.param\\5}, + + "p@22" : [1, {"param@6" : 28}, 2], + "check53" : ${p@22}[1]['param@6'], + "check54" : ${p@22.1.param@6}, + " p23 " : [1, {" param7 " : 28}, 2], + "check55" : ${p23}[1]['param7'], + "check56" : ${p23.1.param7} } diff --git a/test/testfiles/jpp-test_config_0952.jsonp b/test/testfiles/jpp-test_config_0952.jsonp index 940763a..0ed9ad6 100644 --- a/test/testfiles/jpp-test_config_0952.jsonp +++ b/test/testfiles/jpp-test_config_0952.jsonp @@ -13,7 +13,7 @@ // limitations under the License. //************************************************************************** { - "I_am" : "syntax error" - "I_am" : "syntax error" - "I_am" : "syntax error" + "line_1" : "missing comma at end of line 1" + "line_2" : "missing comma at end of line 2" + "line_3" : "line 3" } \ No newline at end of file diff --git a/test/testtools/GenSnippetsJPP.py b/test/testtools/GenSnippetsJPP.py index 5121332..4d74a40 100644 --- a/test/testtools/GenSnippetsJPP.py +++ b/test/testtools/GenSnippetsJPP.py @@ -22,8 +22,8 @@ # # ************************************************************************************************************** # -VERSION = "0.35.0" -VERSION_DATE = "03.01.2025" +VERSION = "0.38.0" +VERSION_DATE = "10.01.2025" # # ************************************************************************************************************** @@ -4022,58 +4022,76 @@ def GetAdditionalBrackets(self): sHeadline = "Additional brackets at several positions within a complex data structure" - # data structure - sDataStructure1 = """ "C" : *01*1, - "params" : *02*[ - *03*2, - *04*{"A" : 3, - *05*"B" : *06*[ - *07*{ - *08*"C" : 4, - *09*${params.1.B.0.C*10*} : 10, - *11*"D" : 5, - *12*${params*13*}*14*[1]*15*['B']*16*[0]*17*['D'*18*] : 11, - "E" : *19*["020", *20*{"021" : "022"*21*}*22*], - "F" : *23*{"023" : *24*["024", "025"*25*]*26*} - *27*}, - 6 - *28*] - *29*}, - 7 - *30*] -""" + # data structure with placeholders + sDataStructurePattern = """ "A" : 1, "B" : 2, "C" : 3, "D" : 4, "E" : 5, "F" : 6, "G" : 7, "H" : 8, "I" : 9, "J" : 10, + "params" : #01#[#02# + #03#11#04#, + #05#{#06#"A" : 12, + "B" : #07#[#08# + #09#{#10# + "C" : 13, + #11#$#12#{params}#13#[#14#1#15#]#16#[#17#'B'#18#]#19#[#20#0#21#]#22#[#23#'C'#24#]#25# : 130, + "D" : 14, + #26#$#27#{params.1.B.0.D}#28# : 140, + "E" : 15, + "F" : 16, + "G" : #29#["017", #30#{#31#"018" : "019"#32#}#33#]#34#, + "H" : #35#[#36#{#37#"020" : "021"#38#}#39#, "022"#40#]#41#, + "I" : #42#{#43#"023" : #44#[#45#"024", "025"#46#]#47#}#48#, + "J" : #49#{#50#"026" : #51#[#52#"027", #53#{#54#"028" : #55#[#56#"029", "030"#57#]#58#}#59#]#60#}#61# + }, + 31 + ] + }, + 32 + ], + ${params}[1]['B'][0]['E'] : 150, + ${params.1.B.0.F} : 160, + #62#$#63#{params}#64#[#65#1#66#]#67#[#68#'B'#69#]#70#[#71#0#72#]#73#[#74#'J'#75#]#76#[#77#'026'#78#]#79#[#80#1#81#]#82#[#83#'028'#84#]#85#[#86#0#87#]#88# : "0290", + ${params.1.B.0.J.026.1.028.1} : "0300" """ sCodeSnippetPattern = """{ ####DATASTRUCTURE#### } """ - # We have a list of expressions and we have a list of placeholders like used in sDataStructure1. + # We have a list of expressions and we have a list of placeholders like used in sDataStructurePattern. # 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 letters) that are only used to complete the code snippet, but are not in focus. + # from a list of filler expressions (empty strings here => placeholders are removed) that are only used to complete + # the code snippet, but are not in focus. - listExpressions = ["{", "}", "[", "]", "$"] + listExpressions = ["{", "}", "[", "]", "(", ")", "[]", "{}"] - listPlaceholders = ["*01*", "*02*", "*03*", "*04*", "*05*", "*06*", "*07*", "*08*", "*09*", "*10*", - "*11*", "*12*", "*13*", "*14*", "*15*", "*16*", "*17*", "*18*", "*19*", "*20*", - "*21*", "*22*", "*23*", "*24*", "*25*", "*26*", "*27*", "*28*", "*29*", "*30*"] + nNrOfPlaceholders = 88 - listPositions = listPlaceholders[:] # to support a nested iteration of the same list; better readibility of code because of different names + listPlaceholders = [] + listFillers = [] + for number in range(1, nNrOfPlaceholders+1): + value = str(number).rjust(2, "0") + listPlaceholders.append(f"#{value}#") + listFillers.append("") - listFiller = ["","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""] # as much elements as in listPlaceholders + listPositions = listPlaceholders[:] # to support a nested iterations of the same list (better readibility of code because of different names) # put all things together listCodeSnippets = [] - # sDataStructure1 + # first snippets is without additions (all placeholders removed) + sDataStructure = sDataStructurePattern # init a new data structure from pattern sDataStructurePattern + sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern + for sPlaceholder in listPlaceholders: + sDataStructure = sDataStructure.replace(sPlaceholder, "") + sCodeSnippet = sCodeSnippet.replace("####DATASTRUCTURE####", sDataStructure) + listCodeSnippets.append(sCodeSnippet) + # following snippets with additions for sExpression in listExpressions: for sPosition in listPositions: - sDataStructure = sDataStructure1 # init a new data structure from pattern sDataStructure1 - sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern - oFiller = CListElements(listFiller) # init a new filler object (= content for remaining placeholders) + sDataStructure = sDataStructurePattern # init a new data structure from pattern sDataStructurePattern + 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: @@ -4092,69 +4110,89 @@ def GetAdditionalBrackets(self): # -------------------------------------------------------------------------------------------------------------- - def GetSpecialCharacters(self): - """Special characters at several positions within a complex data structure + def GetAdditionalCharacters(self): + """Additional characters at several positions within a complex data structure """ - sHeadline = "Special characters at several positions within a complex data structure" - - # data structure 1 - sDataStructure1 = """ "params" : {*01* : *02*, - *03* : [*04*, {*05* : *06*, - *07* : [*08*, [*09*, *10*]], - *11* : [*12*, {*13* : *14*}], - *15* : {*16* : [*17*, *18*]}, - *19* : {*20* : {*21* : *22*}} - } - ] - }""" - - sDefinitions = """ "indexP" : 0, - "keyP" : "A", - "dictP" : {"A" : 0, "B" : 1}, - "listP" : ["A", "B"], -""" + sHeadline = "Additional characters at several positions within a complex data structure" + + # data structure with placeholders + sDataStructurePattern = """ "A" : 1, "B" : 2, "C" : 3, "D" : 4, "E" : 5, "F" : 6, "G" : 7, "H" : 8, "I" : 9, "J" : 10, + "params" : #01#[#02# + #03#11#04#, + #05#{#06#"A" #07#: #08#12, + "B" : #09#[#10# + #11#{#12# + "C" : 13, + #13#$#14#{params}#15#[#16#1#17#]#18#[#19#'B'#20#]#21#[#22#0#23#]#24#[#25#'C'#26#]#27# : 130, + "D" : 14, + #28#$#29#{params.1.B.0.D}#30# : #31#140, + "E" : 15, + "F" : 16, + "G" : ["017", {"018" : "019"}], + "H" : [{"020" : "021"}, "022"], + "I" : {"023" : ["024", "025"]}, + #32#"J"#33# : #34#{#35#"026" #36#:#37# [#38#"027", #39#{#40#"028" : #41#[#42#"029", #43# "030"#44#]#45#}#46#]#47#}#48# + #49#}#50#,#51# + 31 + #52#]#53# + }, + 32 + ], + ${params}[1]['B'][0]['E'] : 150, + ${params.1.B.0.F} : 160, + #54#${params}#55#[#56#1#57#]#58#[#59#'B'#60#]#61#[#62#0#63#]#64#[#65#'J'#66#]#67#[#68#'026'#69#]#70#[#71#1#72#]#73#[#74#'028'#75#]#76#[#77#0#78#]#79# : "0290",#80# + ${params.1.B.0.J.026.1.028.1} : "0300" """ sCodeSnippetPattern = """{ -####DEFINITIONS#### ####DATASTRUCTURE#### } """ - # We have a list of expressions and we have a list of placeholders like used in sDataStructure1. + # We have a list of expressions and we have a list of placeholders like used in sDataStructurePattern. # 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 letters) that are only used to complete the code snippet, but are not in focus. + # from a list of filler expressions (empty strings here => placeholders are removed) that are only used to complete + # the code snippet, but are not in focus. - listExpressions = [".", "..", "[]", "[..]", "[. .]", "{}", "{..}", "{. .}", "/", "\\", "|", "*", "+", "-", "$", "\"", "'", "#", "\"#\"", ":"] + listExpressions = ["+", "-", "*", "/", "_", ".", "..", "$", "'", "\"", "|", ":", "$", "&", "@", "%", "#"] - listPlaceholders = ["*01*", "*02*", "*03*", "*04*", "*05*", "*06*", "*07*", "*08*", "*09*", "*10*", "*11*", - "*12*", "*13*", "*14*", "*15*", "*16*", "*17*", "*18*", "*19*", "*20*", "*21*", "*22*"] + nNrOfPlaceholders = 80 - listPositions = listPlaceholders[:] # to support a nested iteration of the same list; better readibility of code because of different names + listPlaceholders = [] + listFillers = [] + for number in range(1, nNrOfPlaceholders+1): + value = str(number).rjust(2, "0") + listPlaceholders.append(f"#{value}#") + listFillers.append("") - listFiller = ["001","002","003","004","005","006","007","008","009","010", - "011","012","013","014","015","016","017","018","019","020","021","022"] # as much elements as in listPlaceholders + listPositions = listPlaceholders[:] # to support a nested iterations of the same list (better readibility of code because of different names) # put all things together listCodeSnippets = [] - # sDataStructure1 + # first snippets is without additions (all placeholders removed) + sDataStructure = sDataStructurePattern # init a new data structure from pattern sDataStructurePattern + sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern + for sPlaceholder in listPlaceholders: + sDataStructure = sDataStructure.replace(sPlaceholder, "") + sCodeSnippet = sCodeSnippet.replace("####DATASTRUCTURE####", sDataStructure) + listCodeSnippets.append(sCodeSnippet) + # following snippets with additions for sExpression in listExpressions: for sPosition in listPositions: - sDataStructure = sDataStructure1 # init a new data structure from pattern sDataStructure1 - sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern - oFiller = CListElements(listFiller) # init a new filler object (= content for remaining placeholders) + sDataStructure = sDataStructurePattern # init a new data structure from pattern sDataStructurePattern + 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("####DEFINITIONS####", sDefinitions) sCodeSnippet = sCodeSnippet.replace("####DATASTRUCTURE####", sDataStructure) listCodeSnippets.append(sCodeSnippet) # eof for sPosition in listPositions: @@ -4162,7 +4200,7 @@ def GetSpecialCharacters(self): return sHeadline, listCodeSnippets - # eof def GetSpecialCharacters(self): + # eof def GetAdditionalCharacters(self): # -------------------------------------------------------------------------------------------------------------- @@ -4254,7 +4292,7 @@ def GetNamingConventions(self): # expression and placeholder per iteration. All remaining placeholders in current iteration are replaced by elements # from a list of filler expressions (simple letters) that are only used to complete the code snippet, but are not in focus. - listExpressions = ["+", "-", "*", "/" , "|", "$", "%", "#", "\\", "\\\\", "𠼭", "€", "ß", "{", "}", "[", "]", "'"] + listExpressions = ["+", "-", "*", "/" , "|", "$", "%", "#", "\\", "\\\\", "𠼭", "€", "ß", "{", "}", "[", "]", "'", "@", ":", " "] listPlaceholders = ["*01*", "*02*", "*03*", "*04*", "*05*", "*06*"] @@ -4665,7 +4703,7 @@ def GetInternalTokenStrings(self): sHeadline, listCodeSnippets = oSnippets.GetAdditionalBrackets() bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") -sHeadline, listCodeSnippets = oSnippets.GetSpecialCharacters() +sHeadline, listCodeSnippets = oSnippets.GetAdditionalCharacters() bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") sHeadline, listCodeSnippets = oSnippets.GetSlicing()