Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Clean-up Dox generation scripts #212

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 2 additions & 5 deletions Utilities/Dox/PythonScripts/CallerGraphParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
from future.utils import itervalues

import glob
import re
import os
import json
import os.path
import sys
import subprocess
import re
import csv
import argparse
Expand Down Expand Up @@ -494,7 +491,7 @@ def __postParsing__(self, Routine, CrossReference):
logger.warning("invalid Routine Name: %s in routine:%s, package: %s" %
(routineName, Routine, Routine.getPackage()))
return
if (routineName.startswith("%")):
if routineName.startswith("%"):
CrossReference.addPercentRoutine(routineName)
# ignore mumps routine for now
if CrossReference.isMumpsRoutine(routineName):
Expand Down Expand Up @@ -529,7 +526,7 @@ def onSectionStart(self, curLine, sectionHeader, crossRef):
structuredSource=[]
def parseLine(self, line, Routine, CrossReference):
global structuredSource
structuredSource.append(line);
structuredSource.append(line)

#===============================================================================
# Implementation of a Package Object listing parser section
Expand Down
20 changes: 8 additions & 12 deletions Utilities/Dox/PythonScripts/CrossReference.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
from builtins import object
from future.utils import iteritems
from future.utils import itervalues
import sys
import types
import csv
import json
from operator import itemgetter, attrgetter

from LogManager import logger
from UtilityFunctions import PACKAGE_MAP, PACKAGE_COMPONENT_MAP
Expand Down Expand Up @@ -287,7 +283,7 @@ def __repr__(self):
return "Routine: %s" % self._name
def __eq__(self, other):
if not isinstance(other, Routine):
return False;
return False
return self._name == other._name
def __lt__(self, other):
if not isinstance(other, Routine):
Expand Down Expand Up @@ -719,7 +715,7 @@ def setPointedToFiles(self, pointedToFiles):
def getPointedToFiles(self):
return self._pointedToFiles
def __repr__(self):
return ("%s, %s" % (FileManField.__repr__(self), self._pointedToFiles))
return "%s, %s" % (FileManField.__repr__(self), self._pointedToFiles)

class FileManSubFileTypeField(FileManField):
def __init__(self, fieldNo, name, fType ,location = None):
Expand Down Expand Up @@ -825,7 +821,7 @@ def getReferredRoutineByPackage(self, package):
def addPointedToByFile(self, Global, fieldNo, subFileNo=None):
self.__addReferenceGlobalFilesCommon__(Global, fieldNo, subFileNo, True)
Global.__addPointedToFiles__(self, fieldNo, subFileNo)
def getPointedByFilesByPackage(self, Package):
def getPointedByFilesByPackage(self, package):
return self._filePointedBy.get(package)
def __addPointedToFiles__(self, Global, fieldNo, subFileNo):
self.__addReferenceGlobalFilesCommon__(Global, fieldNo, subFileNo, False)
Expand Down Expand Up @@ -867,7 +863,7 @@ def __repr__(self):
return "Global: %s" % self._name
def __eq__(self, other):
if not isinstance(other, Global):
return False;
return False
return self._name == other._name
def __lt__(self, other):
if not isinstance(other, Global):
Expand Down Expand Up @@ -1200,7 +1196,7 @@ def __repr__(self):
return "Package: %s" % self._name
def __eq__(self, other):
if not isinstance(other, Package):
return False;
return False
return self._name == other._name
def __lt__(self, other):
if not isinstance(other, Package):
Expand Down Expand Up @@ -1495,7 +1491,7 @@ def __categorizeVariableNameByNamespace__(self, variableName, isGlobal = False):
if isGlobal:
for globalNameSpace in package.getGlobalNamespace():
if variableName.startswith(globalNameSpace):
return (globalNameSpace, package)
return globalNameSpace, package
for namespace in package.getNamespaces():
if variableName.startswith(namespace):
hasMatch = True
Expand All @@ -1508,8 +1504,8 @@ def __categorizeVariableNameByNamespace__(self, variableName, isGlobal = False):
matchNamespace = ""
break
if hasMatch:
return (matchNamespace, package)
return (None, None)
return matchNamespace, package
return None, None

def __generatePlatformDependentRoutineDependencies__(self):
for genericRoutine in itervalues(self._platformDepRoutines):
Expand Down
20 changes: 9 additions & 11 deletions Utilities/Dox/PythonScripts/FileManGlobalDataParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,18 @@ def _getKeyNameBySchema(self, dataRoot, keyLoc, keyField):
continue
dataEntry = dataEntry[index]
if not dataEntry.value:
return (ien, None)
return ien, None
values = dataEntry.value.split('^')
dataValue = None
if convertToType(loc, int):
intLoc = int(loc)
if intLoc > 0 and intLoc <= len(values):
if 0 < intLoc <= len(values):
dataValue = values[intLoc-1]
else:
dataValue = str(dataEntry.value)
if dataValue:
return (ien, self._parseIndividualFieldDetail(dataValue, keyField, None))
return (None, None)
return ien, self._parseIndividualFieldDetail(dataValue, keyField, None)
return None, None

def parseZWRGlobalFileBySchemaV2(self, inputFileName, fileNumber, glbLoc=None):
schemaFile = self._allSchemaDict[fileNumber]
Expand Down Expand Up @@ -437,14 +437,14 @@ def _updateHL7Reference(self):
protocolEntry = protocol.dataEntries[ien]
if '4' in protocolEntry.fields:
type = protocolEntry.fields['4'].value
if (type != 'event driver' and type != 'subscriber'):
if type != 'event driver' and type != 'subscriber':
entryName = protocolEntry.name
namespace, package = \
self._crossRef.__categorizeVariableNameByNamespace__(entryName)
if package:
package.protocol.append(protocolEntry)
# only care about the event drive and subscriber type
elif (type == 'event driver' or type == 'subscriber'):
elif type == 'event driver' or type == 'subscriber':
entryName = protocolEntry.name
namespace, package = \
self._crossRef.__categorizeVariableNameByNamespace__(entryName)
Expand Down Expand Up @@ -487,13 +487,11 @@ def _updateRPCRefence(self):
if package:
package.rpcs.append(rpcEntry)
else:
logger.error("Cannot find package for RPC: %s" %
(rpcEntry.name))
logger.error("Cannot find package for RPC: %s" % rpcEntry.name)
# Generate the routine referenced based on RPC Call
if rpcRoutine:
rpcInfo = {"name": rpcEntry.name,
"ien" : ien
}
"ien" : ien}
if '.02' in rpcEntry.fields:
rpcTag = rpcEntry.fields['.02'].value
rpcInfo['tag'] = rpcTag
Expand Down Expand Up @@ -579,7 +577,7 @@ def _updateInstallReference(self):
capture = PACKAGE_NAME_VAL_REGEX.match(installEntry.name)
if capture:
checkPackage = self._findInstallPackage(packageList, capture.groups()[0], False)
if ((checkPackage != "Unknown") or (len(capture.groups()[0]) <= 4)):
if (checkPackage != "Unknown") or (len(capture.groups()[0]) <= 4):
installItem['packageSwitch'] = True
installJSONData[package][installEntry.name] = installItem
logger.info("About to dump data into %s" % output)
Expand Down
2 changes: 1 addition & 1 deletion Utilities/Dox/PythonScripts/GenerateNameNumberPages.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generateListingPage(outDir, pageData, dataType):
outputDataListTableHeader(output, dataType, pageData["headers"], pageData["headers"], [])
output.write("<body id=\"dt_example\">")
output.write("""<div id="container" style="width:80%">""")
output.write("<h1> %s Data List</h1>" % (dataType))
output.write("<h1> %s Data List</h1>" % dataType)
outputCustomDataTableHeader(output, pageData["headers"], dataType)
output.write("<tbody>\n")
for object in pageData["records"]:
Expand Down
8 changes: 4 additions & 4 deletions Utilities/Dox/PythonScripts/ICRFileToJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def parse(self, inputFilename, outputFilename):
else:
# Starting to process general description
self._curField = fieldName
self._rewindStack();
self._rewindStack()
self._findKeyValueInLine(match, line)
elif subscribingDetails:
fieldName = 'SUBSCRIBING DETAILS'
Expand Down Expand Up @@ -227,7 +227,7 @@ def _startOfNewItem(self, name, number, matchObj, line):

def _findKeyValueInLine(self, match, line):
""" parse all name value pair in a line and put back in self._curRecord"""
name = match.group('name'); # this is the name part
name = match.group('name') # this is the name part
""" add logic to ignore some of the field """

# now find if there is any other name value pair in the same line
Expand Down Expand Up @@ -294,8 +294,8 @@ def _startOfSubFile(self, match, line):
# just continue with more of the same subfile
# append the previous result
self._curStack[-1][0].setdefault(subFile, []).append(self._curRecord)
break;
else: # this is a different subfile, now check if it is a nested subfile
break
else: # this is a different subfile, now check if it is a nested subfile
if isSubFileField(prevSubFile, subFile):
# this is a nested subFile, push to stack
self._curStack.append((self._curRecord, subFile))
Expand Down
2 changes: 1 addition & 1 deletion Utilities/Dox/PythonScripts/ICRParserTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import ICRParser

from ArgParserHelper import createArgParser
from LogManager import initLogging, logger
from LogManager import initLogging

EXPECTED_PDFS = {
"807": ["ICR-4887.pdf"],
Expand Down
3 changes: 1 addition & 2 deletions Utilities/Dox/PythonScripts/InitCrossReferenceGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
if SCRIPTS_DIR not in sys.path:
sys.path.append(SCRIPTS_DIR)

from ArgParserHelper import createArgParser as createInitialCrossRefGenArgParser
from CrossReference import CrossReference, Routine, Package, Global, PlatformDependentGenericRoutine
from LogManager import logger

Expand Down Expand Up @@ -234,7 +233,7 @@ def findPackagesAndRoutinesBySource(self, dirName, pattern):
crossReference.addRoutineToPackageByName(routineName, packageName)
if needRename:
routine = crossReference.getRoutineByName(routineName)
assert(routine)
assert routine
routine.setOriginalName(origName)
if A_ROUTINE_EX.search(routineName):
pass
Expand Down
3 changes: 0 additions & 3 deletions Utilities/Dox/PythonScripts/LogManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ def initLogging(outputDir, outputFileName, level=logging.DEBUG):
logging.DEBUG, formatter)
_setupConsoleLogging(logging.WARNING, formatter)

def _getTempLogFile(filename):
return os.path.join(tempfile.gettempdir(), filename)

def _setupFileLogging(filename, level, formatter):
fileHandler = logging.FileHandler(filename, 'a')
fileHandler.setLevel(level)
Expand Down
4 changes: 1 addition & 3 deletions Utilities/Dox/PythonScripts/RequirementsJSONtoHTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import json
import argparse
import os.path
import cgi
import sys

from LogManager import logger
from DataTableHtml import outputDataTableHeader, outputDataTableFooter
Expand Down Expand Up @@ -155,7 +153,7 @@ def _generateRequirementsSummaryPageImpl(self, inputJson, listName, pkgName, isF
for reqEntry in reqData:
output.write("<tr>\n")
if not isForAll:
reqSummary = self._convertReqEntryToSummaryInfo(reqEntry);
reqSummary = self._convertReqEntryToSummaryInfo(reqEntry)
if not reqSummary in allReqs:
allReqs.append(reqSummary)
else:
Expand Down
16 changes: 6 additions & 10 deletions Utilities/Dox/PythonScripts/RequirementsXLStoJSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def parseStringVal(value, index):
if re.match(',[ ]*', bffValue) or (bffValue == ''):
continue
if not (bffValue in returnArray):
returnArray.append(bffValue);
returnArray.append(bffValue)
if not (bffValue in rootNode):
rootNode[bffValue] = []
return returnArray
elif index == 4:
returnArray=[]
for nsrEntry in value.split("\n"):
if not (nsrEntry in returnArray):
returnArray.append(nsrEntry);
returnArray.append(nsrEntry)
return returnArray
if not (value.find(" [") == -1):
return value[:value.find(" [")]
Expand Down Expand Up @@ -109,7 +109,7 @@ def parseStringVal(value, index):
def checkReqForUpdate(curNode, pastJSONObj, curDate):
diffFlag=False
foundDate = curDate
noHistory=False;
noHistory=False
BFFList = []
if isinstance(curNode['BFFlink'], list):
for BFFlink in curNode['BFFlink']:
Expand All @@ -120,8 +120,8 @@ def checkReqForUpdate(curNode, pastJSONObj, curDate):
# Remove all recentUpdate attributes
for BFFEntry in BFFList:
if pastJSONObj:
diffFlag=False;
noHistory=False;
diffFlag=False
noHistory=False
if BFFEntry in pastJSONObj:
ret = [x for x in pastJSONObj[BFFEntry] if x['name'] == curNode['name']]
if ret:
Expand All @@ -145,7 +145,7 @@ def checkReqForUpdate(curNode, pastJSONObj, curDate):
curNode['recentUpdate'] = "Update"
curNode['dateUpdated'] = curDate
else:
curNode['recentUpdate'] = "None" if (noHistory) else "New Requirement"
curNode['recentUpdate'] = "None" if noHistory else "New Requirement"
curNode['dateUpdated']= foundDate
rootNode[BFFEntry].append(curNode)

Expand All @@ -163,15 +163,11 @@ def convertExcelToJson(input, output, pastData, curDate):
sheet = book.sheet_by_index(0)
data_row = 1
row_index= 0
fields = None
all_nodes = dict(); # all the nodes
fields = sheet.row_values(row_index)
fields = list(map(RequirementsFieldsConvertFunc, fields))
# Read rest of the BFF data from data_row
for row_index in range(data_row, sheet.nrows):
curNode = dict()
curNode['isRequirement'] = True
curNode['isRequirement'] = True
for col_index in range(sheet.ncols):
cell = sheet.cell(row_index, col_index)
cType = cell.ctype
Expand Down
4 changes: 2 additions & 2 deletions Utilities/Dox/PythonScripts/UtilityFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def getPackageGraphEdgePropsByMetrics(depMetricsList,
edgeStyle = "dotted"
else:
edgeStyle = "solid"
return (edgeLabel, edgeToolTip, edgeStyle)
return edgeLabel, edgeToolTip, edgeStyle

#==============================================================================
## Method to generate merge and sorted Dependeny list by Package
Expand All @@ -404,7 +404,7 @@ def mergeAndSortDependencyListByPackage(package, isDependencyList):
depPackages = sorted(list(depPackageMerged.keys()),
key=lambda item: sum(depPackageMerged[item][0:7:2]),
reverse=True)
return (depPackages, depPackageMerged)
return depPackages, depPackageMerged

#==============================================================================
# Return a dict with package as key, a list of 6 as value
Expand Down
Loading