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
Binary file added JsonPreprocessor/JsonPreprocessor.pdf
Binary file not shown.
23 changes: 23 additions & 0 deletions JsonPreprocessor/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# **************************************************************************************************************
#
# Copyright 2020-2022 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.
#
# **************************************************************************************************************
#
# Version and date of JsonPreprocessor
#
VERSION = "0.1.2"
VERSION_DATE = "01.07.2022"

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,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 <https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/doc/_build/latex/Json-Preprocessor.pdf>`_
A detailed documentation of the Json Preprocessor's package can be found here: `JsonPreprocessor.pdf <https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/JsonPreprocessor/JsonPreprocessor.pdf>`_

Feedback
--------
Expand Down
162 changes: 54 additions & 108 deletions config/CExtendedSetup.py → additions/CExtendedSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,18 @@
#
# CExtendedSetup.py
#
# CM-CI1/ECA3-Queckenstedt
# XC-CT/ECA3-Queckenstedt
#
# Contains all functions to support the extended setup process.
#
# --------------------------------------------------------------------------------------------------------------
#
# 21.02.2022 / XC-CT/ECA3-Queckenstedt
# Added add_htmldoc_to_wheel() to support wheel based distribution
#
# 30.09.2021 / XC-CI1/ECA3-Queckenstedt
# Added wrapper for error messages
#
# Initial version 08/2021
# 10.05.2022
#
# --------------------------------------------------------------------------------------------------------------

import os, sys, platform, shlex, subprocess, shutil
import pypandoc
import colorama as col

col.init(autoreset=True)
Expand Down Expand Up @@ -70,11 +65,11 @@ def __del__(self):

# --------------------------------------------------------------------------------------------------------------

def gen_doc(self):
"""Executes sphinx-makeall.py
def genpackagedoc(self):
"""Executes genpackagedoc.py
"""
sPython = self.__oRepositoryConfig.Get('sPython')
sDocumentationBuilder = self.__oRepositoryConfig.Get('sDocumentationBuilder')
sPython = self.__oRepositoryConfig.Get('PYTHON')
sDocumentationBuilder = self.__oRepositoryConfig.Get('DOCUMENTATIONBUILDER')
listCmdLineParts = []
listCmdLineParts.append(f"\"{sPython}\"")
listCmdLineParts.append(f"\"{sDocumentationBuilder}\"")
Expand All @@ -96,16 +91,58 @@ def gen_doc(self):
return ERROR
print()
return nReturn
# eof def gen_doc():
# eof def genpackagedoc():

# --------------------------------------------------------------------------------------------------------------

def convert_repo_readme(self):
"""Converts the main repository README from 'rst' to 'md' format.
"""

sReadMe_rst = self.__oRepositoryConfig.Get("README_RST")
if sReadMe_rst is None:
print()
printerror(f"'sReadMe_rst' is None")
print()
return ERROR

sReadMe_md = self.__oRepositoryConfig.Get("README_MD")
if sReadMe_md is None:
print()
printerror(f"'sReadMe_md' is None")
print()
return ERROR

if os.path.isfile(sReadMe_rst) is False:
print()
printerror(f"Missing readme file '{sReadMe_rst}'")
print()
return ERROR

sFileContent = pypandoc.convert_file(sReadMe_rst, 'md')
hFile_md = open(sReadMe_md, "w", encoding="utf-8")
listFileContent = sFileContent.splitlines()
for sLine in listFileContent:
hFile_md.write(sLine + "\n")
hFile_md.close()

print(f"File '{sReadMe_rst}'")
print("converted to")
print(f"'{sReadMe_md}'")
print()

return SUCCESS

# eof def convert_repo_readme(self):

# --------------------------------------------------------------------------------------------------------------

def delete_previous_build(self):
"""Deletes folder containing previous builds of setup.py within the repository
"""
sSetupBuildFolder = self.__oRepositoryConfig.Get('sSetupBuildFolder')
sSetupDistFolder = self.__oRepositoryConfig.Get('sSetupDistFolder')
sEggInfoFolder = self.__oRepositoryConfig.Get('sEggInfoFolder')
sSetupBuildFolder = self.__oRepositoryConfig.Get('SETUPBUILDFOLDER')
sSetupDistFolder = self.__oRepositoryConfig.Get('SETUPDISTFOLDER')
sEggInfoFolder = self.__oRepositoryConfig.Get('EGGINFOFOLDER')
if os.path.isdir(sSetupBuildFolder) is True:
print(f"* Deleting '{sSetupBuildFolder}'")
try:
Expand Down Expand Up @@ -141,7 +178,7 @@ def delete_previous_build(self):
def delete_previous_installation(self):
"""Deletes previous package installation folder within the Python installation
"""
sInstalledPackageFolder = self.__oRepositoryConfig.Get('sInstalledPackageFolder')
sInstalledPackageFolder = self.__oRepositoryConfig.Get('INSTALLEDPACKAGEFOLDER')
if os.path.isdir(sInstalledPackageFolder) is True:
print(f"* Deleting '{sInstalledPackageFolder}'")
try:
Expand All @@ -151,102 +188,11 @@ def delete_previous_installation(self):
printexception(str(ex))
print()
return ERROR
sInstalledPackageDocFolder = self.__oRepositoryConfig.Get('sInstalledPackageDocFolder')
if os.path.isdir(sInstalledPackageDocFolder) is True:
print(f"* Deleting '{sInstalledPackageDocFolder}'")
try:
shutil.rmtree(sInstalledPackageDocFolder)
except Exception as ex:
print()
printexception(str(ex))
print()
return ERROR
print()
return SUCCESS

# eof def delete_previous_installation():

# --------------------------------------------------------------------------------------------------------------

def add_htmldoc_to_installation(self):
"""Adds the package documentation in HTML format to the Python onstallation
"""
sHTMLOutputFolder = self.__oRepositoryConfig.Get('sHTMLOutputFolder')
sInstalledPackageDocFolder = self.__oRepositoryConfig.Get('sInstalledPackageDocFolder')
if os.path.isdir(sHTMLOutputFolder) is False:
print()
printerror(f"Error: Missing html output folder '{sHTMLOutputFolder}'")
print()
return ERROR
shutil.copytree(sHTMLOutputFolder, sInstalledPackageDocFolder)
if os.path.isdir(sInstalledPackageDocFolder) is False:
print()
printerror(f"Error: html documentation not copied to package installation folder '{sInstalledPackageDocFolder}'")
print()
return ERROR
print(COLBY + f"Folder '{sHTMLOutputFolder}'")
print(COLBY + "copied to")
print(COLBY + f"'{sInstalledPackageDocFolder}'")
print()
return SUCCESS
# eof def add_htmldoc_to_installation():

# --------------------------------------------------------------------------------------------------------------

def add_htmldoc_to_wheel(self):
"""Adds the package documentation in HTML format to the wheel folder inside build
"""
sHTMLOutputFolder = self.__oRepositoryConfig.Get('sHTMLOutputFolder')
sSetupBuildFolder = self.__oRepositoryConfig.Get('sSetupBuildFolder')
sPackageName = self.__oRepositoryConfig.Get('sPackageName')
if os.path.isdir(sHTMLOutputFolder) is False:
print()
printerror(f"Error: Missing html output folder '{sHTMLOutputFolder}'")
print()
return ERROR

# The desired destination path for the documentation is:
# <build>\bdist.win-amd64\wheel\<package name>\doc
# with <build> is already available by 'sSetupBuildFolder' in CConfig.
# I am not convinced that it's a good idea to have hard coded parts like 'bdist.win-amd64' within a path here.
# Therefore we search recursively the file system for a subfolder with name 'wheel/<package name>'. And that's it!
sTargetFolder = f"wheel/{sPackageName}"
sWheelDocDestPath = None
bBreak = False
for sRootFolder, listFolders, listFiles in os.walk(sSetupBuildFolder):
for sFolder in listFolders:
sPath = os.path.join(sRootFolder, sFolder)
sPathMod = sPath.replace("\\", "/")
if sPathMod.endswith(sTargetFolder):
sWheelDocDestPath = f"{sPathMod}/doc"
bBreak = True
break # for sFolder in listFolders:
# eof if sPathMod.endswith(sTargetFolder):
# eof for sFolder in listFolders:
if bBreak is True:
break # walk
# eof for sRootFolder, listFolders, listFiles in os.walk(sSetupBuildFolder):

if sWheelDocDestPath is None:
print()
printerror(f"Error: Not able to find '{sTargetFolder}' inside {sSetupBuildFolder}")
print()
return ERROR

shutil.copytree(sHTMLOutputFolder, sWheelDocDestPath)
if os.path.isdir(sWheelDocDestPath) is False:
print()
printerror(f"Error: html documentation not copied to local wheel folder '{sWheelDocDestPath}'")
print()
return ERROR

print(COLBY + f"Folder '{sHTMLOutputFolder}'")
print(COLBY + "copied to")
print(COLBY + f"'{sWheelDocDestPath}'")
print()
return SUCCESS
# eof def add_htmldoc_to_wheel():

# eof class CExtendedSetup():

# --------------------------------------------------------------------------------------------------------------
Expand Down
Loading