diff --git a/README.rst b/README.rst index 0276f745..81dbf178 100644 --- a/README.rst +++ b/README.rst @@ -18,10 +18,15 @@ Json Preprocessor's Package Description Getting Started --------------- -The JsonPreprocessor is a python3 package which allows programmers to handle -additional features in json files such as comments, imports, overrides, etc. -The json files containing comments, imports,... will be handled by the JsonPreprocessor -package which returs as result an dictionary object of the deserialized data. +The JsonPreprocessor is a Python3 package which allows programmers to handle +additional features in json files such as + +* add comments +* import other json files +* overwrite already existing parameters with new values + +These json files will be handled by the JsonPreprocessor which returns as result +a dictionary object of the deserialized data. How to install -------------- @@ -42,7 +47,7 @@ package documentation is located in 'doc/_build/'. Package Documentation --------------------- -A detailed documentation of the Json Preprocessor's Package can be found here: `Json-Preprocessor.pdf `_ +A detailed documentation of the Json Preprocessor's package can be found here: `Json-Preprocessor.pdf `_ Feedback -------- diff --git a/config/CConfig.py b/config/CConfig.py index 8e9e8a72..705350d6 100644 --- a/config/CConfig.py +++ b/config/CConfig.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Copyright 2020-2022 Robert Bosch Car Multimedia GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +16,7 @@ # # CConfig.py # -# CM-CI1/ECA3-Queckenstedt +# XC-CT/ECA3-Queckenstedt # # Purpose: # - Compute and store all repository specific information, like the repository name, @@ -31,13 +29,16 @@ # (when documentation project files like make.bat are generated by Sphinx; for better understanding # no new names here). # -# - Output in PDF format requires LaTeX compiler and self.__bGenPDFSupported set to True (True is default) +# - Output in PDF format requires LaTeX compiler and depends on %ROBOTLATEXPATH%/miktex/bin/x64/pdflatex.exe # # - Don't be confused: We have 'doc/_build' containing the documentation builder output # and we have 'build' containing the build of the setup tools. These are different things. # # -------------------------------------------------------------------------------------------------------------- # +# 18.02.2022 / XC-CT/ECA3-Queckenstedt +# Usage of %RobotPythonPath% exchanged by sys.executable +# # 11.10.2021 / XC-CI1/ECA3-Queckenstedt # Fixed path within site-packages (Linux) # @@ -81,8 +82,6 @@ def __init__(self, sReferencePath="."): self.__sReferencePath = os.path.normpath(os.path.abspath(sReferencePath)) self.__dictConfig['sReferencePath'] = self.__sReferencePath # only to have the possibility to print out all values only with help of 'self.__dictConfig' - self.__bGenPDFSupported = False - # 1. basic setup stuff self.__dictConfig['sPackageName'] = "JsonPreprocessor" self.__dictConfig['sVersion'] = "0.0.10" @@ -117,84 +116,53 @@ def __InitConfig(self): sOSName = os.name sPlatformSystem = platform.system() + sPythonPath = os.path.dirname(sys.executable) + sPython = sys.executable + sPythonVersion = sys.version SPHINXBUILD = None - sPython = None sLaTeXInterpreter = None sInstalledPackageFolder = None sInstalledPackageDocFolder = None try: - self.__dictConfig['sPythonVersion'] = sys.version - self.__dictConfig['sPandoc'] = pypandoc.get_pandoc_path() + self.__dictConfig['sPandoc'] = pypandoc.get_pandoc_path() except Exception as ex: bSuccess = False sResult = str(ex) return bSuccess, sResult if sPlatformSystem == "Windows": - # -- environment check - 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. -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")) - 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")) + SPHINXBUILD = f"{sPythonPath}/Scripts/sphinx-build.exe" + sInstalledPackageFolder = f"{sPythonPath}/Lib/site-packages/" + self.__dictConfig['sPackageName'] + sInstalledPackageDocFolder = f"{sPythonPath}/Lib/site-packages/" + self.__dictConfig['sPackageName'] + "_doc" + sLaTeXInterpreter = os.path.normpath(os.path.expandvars("%ROBOTLATEXPATH%/miktex/bin/x64/pdflatex.exe")) elif sPlatformSystem == "Linux": - # -- environment check - sRobotPythonPath_EnvVar = "${RobotPythonPath}" - sRobotPythonPath = os.path.expandvars(sRobotPythonPath_EnvVar) - if sRobotPythonPath_EnvVar == sRobotPythonPath: - # environment variable not resolved => not existing - bSuccess = False - sResult = f"""Missing Linux environment variable ${RobotPythonPath}! -This application requires a Linux 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}/sphinx-build")) - sPython = os.path.normpath(os.path.expandvars("${RobotPythonPath}/python3.9")) - # if self.__bGenPDFSupported is True: # not yet!! - # sLaTeXInterpreter = os.path.normpath(os.path.expandvars("${ROBOTLATEXPATH}/miktex/bin/x64/pdflatex")) - sInstalledPackageFolder = os.path.normpath(os.path.expandvars("${RobotPythonPath}/../lib/python3.9/site-packages/" + self.__dictConfig['sPackageName'])) - sInstalledPackageDocFolder = os.path.normpath(os.path.expandvars("${RobotPythonPath}/../lib/python3.9/site-packages/" + self.__dictConfig['sPackageName'] + "_doc")) + SPHINXBUILD = f"{sPythonPath}/sphinx-build" + sInstalledPackageFolder = f"{sPythonPath}/../lib/python3.9/site-packages/" + self.__dictConfig['sPackageName'] + sInstalledPackageDocFolder = f"{sPythonPath}/../lib/python3.9/site-packages/" + self.__dictConfig['sPackageName'] + "_doc" + sLaTeXInterpreter = os.path.normpath(os.path.expandvars("${ROBOTLATEXPATH}/miktex/bin/x64/pdflatex")) else: bSuccess = False - sResult = "Operating system " + str(sPlatformSystem) + " (" + str(sOSName) + ") not supported" + sResult = f"Operating system {sPlatformSystem} ({sOSName}) not supported" return bSuccess, sResult - self.__dictConfig['SPHINXBUILD'] = SPHINXBUILD - self.__dictConfig['sPython'] = sPython - self.__dictConfig['sLaTeXInterpreter'] = sLaTeXInterpreter - self.__dictConfig['sInstalledPackageFolder'] = sInstalledPackageFolder - self.__dictConfig['sInstalledPackageDocFolder'] = sInstalledPackageDocFolder + if os.path.isfile(sLaTeXInterpreter) is False: + sLaTeXInterpreter = None # not an error; PDF generation is an option if os.path.isfile(SPHINXBUILD) is False: bSuccess = False - sResult = "Missing Sphinx '" + str(SPHINXBUILD) + "'" + sResult = f"Missing Sphinx '{SPHINXBUILD}'" return bSuccess, sResult - if os.path.isfile(sPython) is False: - bSuccess = False - sResult = "Missing Python '" + str(sPython) + "'" - return bSuccess, sResult + self.__dictConfig['SPHINXBUILD'] = SPHINXBUILD + self.__dictConfig['sPython'] = sPython + self.__dictConfig['sLaTeXInterpreter'] = sLaTeXInterpreter + self.__dictConfig['sInstalledPackageFolder'] = sInstalledPackageFolder + self.__dictConfig['sInstalledPackageDocFolder'] = sInstalledPackageDocFolder - if self.__bGenPDFSupported is True: - if os.path.isfile(sLaTeXInterpreter) is False: - bSuccess = False - sResult = "Missing LaTeX '" + str(sLaTeXInterpreter) + "'" - return bSuccess, sResult # ---- paths relative to repository root folder (where the srcipts are located that use this module) @@ -233,7 +201,7 @@ def __InitConfig(self): self.__dictConfig['sEggInfoFolder'] = os.path.normpath(self.__sReferencePath + "/" + self.__dictConfig['sPackageName'] + ".egg-info") print() - print("Running under " + str(sPlatformSystem) + " (" + str(sOSName) + ")") + print(f"Running under {sPlatformSystem} ({sOSName})") self.PrintConfig() bSuccess = True @@ -256,7 +224,7 @@ def PrintConfig(self): def Get(self, sName=None): if ( (sName is None) or (sName not in self.__dictConfig) ): print() - printerror("Error: Configuration parameter '" + str(sName) + "' not existing!") + printerror(f"Error: Configuration parameter '{sName}' not existing!") # from here it's standard output: print("Use instead one of:") self.PrintConfig() diff --git a/config/CExtendedSetup.py b/config/CExtendedSetup.py index 66e68089..26d3d14c 100644 --- a/config/CExtendedSetup.py +++ b/config/CExtendedSetup.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Copyright 2020-2022 Robert Bosch Car Multimedia GmbH # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -73,8 +71,8 @@ def gen_doc(self): sPython = self.__oRepositoryConfig.Get('sPython') sDocumentationBuilder = self.__oRepositoryConfig.Get('sDocumentationBuilder') listCmdLineParts = [] - listCmdLineParts.append("\"" + str(sPython) + "\"") - listCmdLineParts.append("\"" + str(sDocumentationBuilder) + "\"") + listCmdLineParts.append(f"\"{sPython}\"") + listCmdLineParts.append(f"\"{sDocumentationBuilder}\"") sCmdLine = " ".join(listCmdLineParts) del listCmdLineParts listCmdLineParts = shlex.split(sCmdLine) @@ -104,7 +102,7 @@ def delete_previous_build(self): sSetupDistFolder = self.__oRepositoryConfig.Get('sSetupDistFolder') sEggInfoFolder = self.__oRepositoryConfig.Get('sEggInfoFolder') if os.path.isdir(sSetupBuildFolder) is True: - print("* Deleting '" + sSetupBuildFolder + "'") + print(f"* Deleting '{sSetupBuildFolder}'") try: shutil.rmtree(sSetupBuildFolder) except Exception as ex: @@ -113,7 +111,7 @@ def delete_previous_build(self): print() return ERROR if os.path.isdir(sSetupDistFolder) is True: - print("* Deleting '" + sSetupDistFolder + "'") + print(f"* Deleting '{sSetupDistFolder}'") try: shutil.rmtree(sSetupDistFolder) except Exception as ex: @@ -122,7 +120,7 @@ def delete_previous_build(self): print() return ERROR if os.path.isdir(sEggInfoFolder) is True: - print("* Deleting '" + sEggInfoFolder + "'") + print(f"* Deleting '{sEggInfoFolder}'") try: shutil.rmtree(sEggInfoFolder) except Exception as ex: @@ -140,7 +138,7 @@ def delete_previous_installation(self): """ sInstalledPackageFolder = self.__oRepositoryConfig.Get('sInstalledPackageFolder') if os.path.isdir(sInstalledPackageFolder) is True: - print("* Deleting '" + sInstalledPackageFolder + "'") + print(f"* Deleting '{sInstalledPackageFolder}'") try: shutil.rmtree(sInstalledPackageFolder) except Exception as ex: @@ -150,7 +148,7 @@ def delete_previous_installation(self): return ERROR sInstalledPackageDocFolder = self.__oRepositoryConfig.Get('sInstalledPackageDocFolder') if os.path.isdir(sInstalledPackageDocFolder) is True: - print("* Deleting '" + sInstalledPackageDocFolder + "'") + print(f"* Deleting '{sInstalledPackageDocFolder}'") try: shutil.rmtree(sInstalledPackageDocFolder) except Exception as ex: @@ -172,18 +170,18 @@ def add_htmldoc_to_installation(self): sInstalledPackageDocFolder = self.__oRepositoryConfig.Get('sInstalledPackageDocFolder') if os.path.isdir(sHTMLOutputFolder) is False: print() - printerror("Error: Missing html output folder '" + sHTMLOutputFolder + "'") + printerror(f"Error: Missing html output folder '{sHTMLOutputFolder}'") print() return ERROR shutil.copytree(sHTMLOutputFolder, sInstalledPackageDocFolder) if os.path.isdir(sInstalledPackageDocFolder) is False: print() - printerror("Error: html documentation not copied to package installation folder '" + sInstalledPackageDocFolder + "'") + printerror(f"Error: html documentation not copied to package installation folder '{sInstalledPackageDocFolder}'") print() return ERROR - print(COLBY + "Folder '" + sHTMLOutputFolder + "'") + print(COLBY + f"Folder '{sHTMLOutputFolder}'") print(COLBY + "copied to") - print(COLBY + "'" + sInstalledPackageDocFolder + "'") + print(COLBY + f"'{sInstalledPackageDocFolder}'") print() return SUCCESS # eof def add_htmldoc_to_installation(): diff --git a/doc/_build/latex/Json-Preprocessor.pdf b/doc/_build/latex/Json-Preprocessor.pdf index 18fbe515..2af449d2 100644 Binary files a/doc/_build/latex/Json-Preprocessor.pdf and b/doc/_build/latex/Json-Preprocessor.pdf differ diff --git a/doc/additional_doc/feature_documentation.rst b/doc/additional_doc/feature_documentation.rst index 62a4def3..36a3eacd 100644 --- a/doc/additional_doc/feature_documentation.rst +++ b/doc/additional_doc/feature_documentation.rst @@ -20,11 +20,15 @@ Introduction: .. image:: /images/python3-jsonpreprocessor.png -The JsonPreprocessor is the python3 package which allows programmer to handle some -additional features in json file such as comment, import, override, etc for -configuring purpose. The json file containing comment, import,... will be handled -by JsonPreprocessor package then returned the final dictionary object for python -program. +The JsonPreprocessor is a Python3 package which allows programmers to handle +additional features in json files such as + +* add comments +* import other json files +* overwrite already existing parameters with new values + +These json files will be handled by the JsonPreprocessor package which returns as result +a dictionary object of the deserialized data. New features ~~~~~~~~~~~~ @@ -42,17 +46,14 @@ Features in details Adding comments to Json file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The JsonPreprocessor allows adding comments into json file, a comment could be -added follow **"//"**. -This is required becuase some big projects require a large json configuration file -which contains a huge number of configuration parameters for the different features. -Therefore, having the need of adding comments into json file to clarify the different -configuration parameters. +Every line starting with **"//"**, is commented out. Therefore a comment is valid for singles lines only. + +Comment out a block of several lines with only one start and one end comment string, is currently not supported. -**Note:** This package is not allow commented a block of json code, each comment -must be added with **"//"**. +Adding comments to json files is useful in case of more and more content is added, e.g. because of a json file +has to hold a huge number of configuration parameters for different features. Comments can be used here +to clarify the meaning of these parameters or the differences between them. **Example:** @@ -102,13 +103,12 @@ must be added with **"//"**. Import the contents from other json files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This import feature allows user merges the content of other json files into the -json file, it also allows the nested importing means we can use import feature in -the imported files. +This import feature enables developers to take over the content of other json files into the +current json file. A json file that is imported into another json file, can contain imports also +(allows nested imports). -The import feature helps user distinguish the configuration parameters of each -functions, purposes, variants, and so forth into the separate json files. Therefore, -we can easy to understand and manage the configuration parameters of big project. +A possible usecase for nested imports is to handle similar configuration parameters of different variants of a feature +or a component within a bunch of several smaller files, instead of putting all parameter into only one large json file. **Example:** diff --git a/setup.py b/setup.py index 29a1b219..3e36b422 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,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 -*- + # ************************************************************************************************************** # @@ -27,8 +27,8 @@ # This script deletes folders (as defined in config.CConfig, depending on the position of this script): # - previous builds within this repository # - previous installations within -# * %ROBOTPYTHONPATH%\Lib\site-packages (Windows) -# * ${RobotPythonPath}/../lib/python3.9/site-packages (Linux) +# * \Lib\site-packages (Windows) +# * /../lib/python3.9/site-packages (Linux) # # before the build and the installation start again! # @@ -49,11 +49,11 @@ # # * Known issues: # -# - setuptools do not properly update an existing package installation under %ROBOTPYTHONPATH%\Lib\site-packages\! +# - setuptools do not properly update an existing package installation under \Lib\site-packages\! # > Files modified manually within installation folder, are still modified after repeated execution of setuptools. # > Files added manually within installation folder, are still present there after repeated execution of setuptools. # > Only files deleted manually within installation folder, are are restored there after repeated execution of setuptools. -# - No such issues with %ROBOTPYTHONPATH%\Lib\site-packages\-.egg-info. +# - No such issues with \Lib\site-packages\-.egg-info. # - Solution: explicit deletion of all previous output (all documentation-, build- and installation-folder, except the egg-info folder) # (see 'delete_previous_build()' and 'delete_previous_installation()') # @@ -61,7 +61,7 @@ # # 09.02.2022 / XC-CT/ECA3-Queckenstedt # Suppressed generation of documents and installations in case of command line -# parameter is not 'install' and not 'build' (this enables printing the help only). +# parameter is not 'install' and not 'build' (this enables printing the help only). (10.02.2022: and not 'sdist') # # 11.10.2021 / XC-CI1/ECA3-Queckenstedt # Fixed computation order of readme files together with long_description @@ -109,7 +109,7 @@ def run(self): # Extended installation step 1/5 (documentation builder) moved to outside ExtendedInstallCommand because results are needed earlier listCmdArgs = sys.argv - if ( ('install' in listCmdArgs) or ('build' in listCmdArgs) or ('sdist' in listCmdArgs)): + if ( ('install' in listCmdArgs) or ('build' in listCmdArgs) or ('sdist' in listCmdArgs) or ('bdist_wheel' in listCmdArgs) ): print() print(COLBY + "Extended setup (install) step 2/5: Deleting previous setup outputs (build, dist, .egg-info within repository)") print() @@ -117,7 +117,7 @@ def run(self): if nReturn != SUCCESS: return nReturn print() - print(COLBY + "Extended setup (install) step 3/5: Deleting previous package installation folder within site-packages") # ( and _doc under %ROBOTPYTHONPATH%\Lib\site-packages + print(COLBY + "Extended setup (install) step 3/5: Deleting previous package installation folder within site-packages") # ( and _doc under \Lib\site-packages print() nReturn = oExtendedSetup.delete_previous_installation() if nReturn != SUCCESS: @@ -126,7 +126,7 @@ def run(self): print() install.run(self) # TODO: What does install.run(self) return? How to realize error handling? print() - print(COLBY + "Extended setup (install) step 5/5: Add html documentation to package installation folder") # (./doc/_build/html to %ROBOTPYTHONPATH%\Lib\site-packages\_doc) + print(COLBY + "Extended setup (install) step 5/5: Add html documentation to package installation folder") # (./doc/_build/html to \Lib\site-packages\_doc) print() nReturn = oExtendedSetup.add_htmldoc_to_installation() if nReturn != SUCCESS: @@ -170,7 +170,7 @@ def run(self): long_description = "long description" # variable is required even in case of other command line parameters than 'install' or 'build' are used listCmdArgs = sys.argv -if ( ('install' in listCmdArgs) or ('build' in listCmdArgs) or ('sdist' in listCmdArgs)): +if ( ('install' in listCmdArgs) or ('build' in listCmdArgs) or ('sdist' in listCmdArgs) or ('bdist_wheel' in listCmdArgs) ): print() print(COLBY + "Entering extended installation") print() @@ -185,9 +185,6 @@ def run(self): with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() - print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") - print(long_description) - print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") # -------------------------------------------------------------------------------------------------------------- diff --git a/sphinx-makeall.py b/sphinx-makeall.py index a985ac95..8dea34bf 100644 --- a/sphinx-makeall.py +++ b/sphinx-makeall.py @@ -11,7 +11,6 @@ # 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 -*- # ************************************************************************************************************** # @@ -96,7 +95,7 @@ def convert_repo_readme(oRepositoryConfig=None): if os.path.isfile(sReadMe_rst) is False: print() - printerror("Missing readme file '" + sReadMe_rst + "'") + printerror(f"Missing readme file '{sReadMe_rst}'") print() return ERROR @@ -108,9 +107,9 @@ def convert_repo_readme(oRepositoryConfig=None): hFile_md.close() print() - print(COLBY + "File '" + sReadMe_rst + "'") + print(COLBY + f"File '{sReadMe_rst}'") print(COLBY + "converted to") - print(COLBY + "'" + sReadMe_md + "'") + print(COLBY + f"'{sReadMe_md}'") print() return SUCCESS @@ -152,11 +151,11 @@ def sphinx_build(sFormat=None, oRepositoryConfig=None): return ERROR listCmdLineParts = [] - listCmdLineParts.append("\"" + str(sPython) + "\"") - listCmdLineParts.append("\"" + str(SPHINXBUILD) + "\"") - listCmdLineParts.append("-M " + sFormat) - listCmdLineParts.append("\"" + str(SOURCEDIR) + "\"") - listCmdLineParts.append("\"" + str(BUILDDIR) + "\"") + listCmdLineParts.append(f"\"{sPython}\"") + listCmdLineParts.append(f"\"{SPHINXBUILD}\"") + listCmdLineParts.append(f"-M {sFormat}") + listCmdLineParts.append(f"\"{SOURCEDIR}\"") + listCmdLineParts.append(f"\"{BUILDDIR}\"") sCmdLine = " ".join(listCmdLineParts) del listCmdLineParts @@ -205,10 +204,10 @@ def gen_doc_pdf(oRepositoryConfig=None): return ERROR # LaTeX sources are placed by Sphinx within subfolder 'latex' of folder 'BUILDDIR' - sLaTeXRoot = os.path.normpath(BUILDDIR + "/latex") # not part of oRepositoryConfig; only needed here! + sLaTeXRoot = os.path.normpath(f"{BUILDDIR}/latex") # not part of oRepositoryConfig; only needed here! if os.path.isdir(sLaTeXRoot) is False: print() - printerror("Missing LaTeX documentation folder '" + str(sLaTeXRoot) + "'") + printerror(f"Missing LaTeX documentation folder '{sLaTeXRoot}'") print() return ERROR @@ -223,17 +222,17 @@ def gen_doc_pdf(oRepositoryConfig=None): if len(listTeXFiles) == 0: print() - printerror("Missing LaTeX source files (.tex) within '" + str(sLaTeXRoot) + "'") + printerror(f"Missing LaTeX source files (.tex) within '{sLaTeXRoot}'") print() return ERROR for sTeXFile in listTeXFiles: - print(COLBY + "* Rendering file '" + sTeXFile + "'") + print(COLBY + f"* Rendering file '{sTeXFile}'") print() listCmdLineParts = [] - listCmdLineParts.append("\"" + str(sLaTeXInterpreter) + "\"") - listCmdLineParts.append("\"" + str(sTeXFile) + "\"") + listCmdLineParts.append(f"\"{sLaTeXInterpreter}\"") + listCmdLineParts.append(f"\"{sTeXFile}\"") sCmdLine = " ".join(listCmdLineParts) del listCmdLineParts @@ -250,7 +249,7 @@ def gen_doc_pdf(oRepositoryConfig=None): os.chdir(sLaTeXRoot) # otherwise LaTeX compiler is not able to find files inside nReturn = subprocess.call(listCmdLineParts) print() - print("LaTeX compiler returned " + str(nReturn)) + print(f"LaTeX compiler returned {nReturn}") print() os.chdir(cwd) # restore original value except Exception as ex: @@ -260,7 +259,7 @@ def gen_doc_pdf(oRepositoryConfig=None): return ERROR if nReturn != SUCCESS: - printerror("LaTeX compiler not returned expected value " + str(SUCCESS)) + printerror(f"LaTeX compiler not returned expected value {SUCCESS}") print() return nReturn @@ -269,7 +268,7 @@ def gen_doc_pdf(oRepositoryConfig=None): for name in files: if name.lower().endswith(".pdf"): sPDFFile = os.path.join(root, name) - print(COLBY + "* Created '" + sPDFFile + "'") + print(COLBY + f"* Created '{sPDFFile}'") print() return nReturn