Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 11 additions & 164 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
See the License for the specific language governing permissions and
limitations under the License.

JSONPREPROCESSOR DOCUMENTATION
==============================
Json Preprocessor's Package Description
=======================================

Getting Started
---------------
Expand All @@ -24,7 +24,7 @@ The json files containing comments, imports,... will be handled by the JsonPrepr
package which returs as result an dictionary object of the deserialized data.

How to install
~~~~~~~~~~~~~~
--------------

Firstly, clone **python-jsonpreprocessor** repository to your machine.

Expand All @@ -36,183 +36,30 @@ Then go to python-jsonpreprocessor, using the 2 common commands below to build o
setup.py install will install the package

After the build processes is completed, the package is located in 'build/', and the generated
documents are located in 'doc/_build/'.
package documentation is located in 'doc/_build/'.

Features
--------

Adding comments to json file:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The JsonPreprocessor allows adding comments into a json file, a comment can be added
anywhere after **"//"**.

**Note:** This package is not supporting multiline comments. Only single line comments
are possible.

**Example:**

.. code-block::

//*****************************************************************************
// Author: ROBFW-AIO Team
//
// This file defines all common global parameters and will be included to all
// test config files
//*****************************************************************************
{
"Project": "G3g",
"WelcomeString": "Hello... ROBFW is running now!",
// Version control information.
"version": {
"majorversion": "0",
"minorversion": "1",
"patchversion": "1"
},
"TargetName" : "gen3flex@dlt"
}

Import other json files:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The import feature allows users to merge the content of other json files into a json
file, it also allows nested importing, means we can use import feature again in imported
files.

**Example:**
Package Documentation
---------------------

.. code-block::

//*****************************************************************************
// Author: ROBFW-AIO Team
//
// This file defines all common global parameters and will be included to all
// test config files
//*****************************************************************************
{
"Project": "G3g",
"WelcomeString": "Hello... ROBFW is running now!",
// Version control information.
"version": {
"majorversion": "0",
"minorversion": "1",
"patchversion": "1"
},
"params": {
// Global parameters
"global": {
"[import]": "<path_to_the_imported_file>/params_global.json"
}
},
"preprocessor": {
"definitions": {
// FEATURE switches
"[import]": "<path_to_the_imported_file>/preprocessor_definitions.json"
}
},
"TargetName" : "gen3flex@dlt"
}

Override, update and add new parameters:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This package also allows to override, update and adding new parameters.
User can update parameters which are already declared and add new parameters or new
elements into existing parameters. The below example will show the way to use these features.

**Example:**

.. code-block::

{
"Project": "G3g",
"WelcomeString": "Hello... ROBFW is running now!",
// Version control information.
"version": {
"majorversion": "0",
"minorversion": "1",
"patchversion": "1"
},
"params": {
// Global parameters
"global": {
"[import]": "<path_to_the_imported_file>/params_global.json"
}
},
"TargetName" : "gen3flex@dlt",
// Override parameters
"${params}['global']['gGlobalFloatParam']": 9.999,
"${version}['patchversion']": "2",
"${params}['global']['gGlobalString']": "This is new string after overrided",
// Add new parameters
"${newParam}": {
"abc": 9,
"xyz": "new param"
},
"${params}['global']['gGlobalStructure']['newGlobalParam']": 123
}

Nested parameters:
~~~~~~~~~~~~~~~~~~

With the JsonPreprocessor package, a user can also use nested parameters:

**Example:**

.. code-block::
A detailed documentation of the Json Preprocessor's Package can be found here: `thejsonpreprocessor.pdf <https://github.com/test-fullautomation/python-jsonpreprocessor/blob/qth2hi/task/documentation_and_sphinx_config_maintenance/doc/_build/latex/thejsonpreprocessor.pdf>`_

{
"Project": "G3g",
"WelcomeString": "Hello... ROBFW is running now!",
// Version control information.
"version": {
"majorversion": "0",
"minorversion": "1",
"patchversion": "1"
},
"params": {
// Global parameters
"global": {
"gGlobalIntParam" : 1,
"gGlobalFloatParam" : 1.332, // This parameter is used to configure for ....
"gGlobalString" : "This is a string",
"gGlobalStructure": {
"general": "general"
}
}
},
"preprocessor": {
"definitions": {
"gPreprolIntParam" : 1,
"gPreproFloatParam" : 9.664,
"ABC": "checkABC",
"gPreproString" : "This is a string",
"gPreproStructure": {
"general": "general"
}
}
},
"TargetName" : "gen3flex@dlt",
// Nested parameter
"${params}['global'][${preprocessor}['definitions']['ABC']]": true,
"${params}['global']['gGlobalFloatParam']": "${preprocessor}['definitions']['gPreproFloatParam']"
}

Feedback
--------

To give us a feedback, you can send an email to `Thomas Pollerspöck <Thomas.Pollerspoeck@de.bosch.com>`
To give us a feedback, you can send an email to `Thomas Pollerspöck <Thomas.Pollerspoeck@de.bosch.com>`_

In case you want to report a bug or request any interesting feature, please don't
hesitate to raise a ticket.

Maintainers
~~~~~~~~~~~
-----------

`Thomas Pollerspöck <Thomas.Pollerspoeck@de.bosch.com>`_

Contributors
~~~~~~~~~~~~
------------

`Mai Dinh Nam Son <son.maidinhnam@vn.bosch.com>`_

Expand All @@ -224,4 +71,4 @@ License
json-preprocessor is open source software provided under the `Apache License
2.0`__.

__ http://apache.org/licenses/LICENSE-2.0
__ http://apache.org/licenses/LICENSE-2.0
19 changes: 10 additions & 9 deletions config/CConfig.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020-2022 Robert Bosch Car Multimedia GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -11,8 +13,7 @@
# 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.
# -*- coding: utf-8 -*-

#
# **************************************************************************************************************
#
# CConfig.py
Expand Down Expand Up @@ -133,22 +134,22 @@ def __InitConfig(self):

if sPlatformSystem == "Windows":
# -- environment check
sRobotPythonPath_EnvVar = "%ROBOTPYTHONPATH%"
sRobotPythonPath_EnvVar = "%RobotPythonPath%"
sRobotPythonPath = os.path.expandvars(sRobotPythonPath_EnvVar)
if sRobotPythonPath_EnvVar == sRobotPythonPath:
# environment variable not resolved => not existing
bSuccess = False
sResult = f"""Missing Windows environment variable %ROBOTPYTHONPATH%!
This application requires a Windows environment variable %ROBOTPYTHONPATH%, pointing to a Python installation (version required: {self.__dictConfig['sPythonRequires']}) that shall be updated.
sResult = f"""Missing Windows environment variable %RobotPythonPath%!
This application requires a Windows environment variable %RobotPythonPath%, pointing to a Python installation (version required: {self.__dictConfig['sPythonRequires']}) that shall be updated.
Please create and try again"""
return bSuccess, sResult

SPHINXBUILD = os.path.normpath(os.path.expandvars("%ROBOTPYTHONPATH%/Scripts/sphinx-build.exe"))
sPython = os.path.normpath(os.path.expandvars("%ROBOTPYTHONPATH%/python.exe"))
SPHINXBUILD = os.path.normpath(os.path.expandvars("%RobotPythonPath%/Scripts/sphinx-build.exe"))
sPython = os.path.normpath(os.path.expandvars("%RobotPythonPath%/python.exe"))
if self.__bGenPDFSupported is True:
sLaTeXInterpreter = os.path.normpath(os.path.expandvars("%ROBOTLATEXPATH%/miktex/bin/x64/pdflatex.exe"))
sInstalledPackageFolder = os.path.normpath(os.path.expandvars("%ROBOTPYTHONPATH%/Lib/site-packages/" + self.__dictConfig['sPackageName']))
sInstalledPackageDocFolder = os.path.normpath(os.path.expandvars("%ROBOTPYTHONPATH%/Lib/site-packages/" + self.__dictConfig['sPackageName'] + "_doc"))
sInstalledPackageFolder = os.path.normpath(os.path.expandvars("%RobotPythonPath%/Lib/site-packages/" + self.__dictConfig['sPackageName']))
sInstalledPackageDocFolder = os.path.normpath(os.path.expandvars("%RobotPythonPath%/Lib/site-packages/" + self.__dictConfig['sPackageName'] + "_doc"))

elif sPlatformSystem == "Linux":
# -- environment check
Expand Down
5 changes: 3 additions & 2 deletions config/CExtendedSetup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020-2022 Robert Bosch Car Multimedia GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -11,8 +13,7 @@
# 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.
# -*- coding: utf-8 -*-

#
# **************************************************************************************************************
#
# CExtendedSetup.py
Expand Down
Loading