From 1e26b3db9fb3c48e9cf18a0d603848750d95d66f Mon Sep 17 00:00:00 2001 From: Betsy McPhail Date: Mon, 21 Oct 2019 22:05:47 -0400 Subject: [PATCH] Clean-up Dox generation scripts * Remove unused imports * Remove extra ()'s * Remove ;'s --- .../Dox/PythonScripts/CallerGraphParser.py | 7 +- Utilities/Dox/PythonScripts/CrossReference.py | 20 +++--- .../PythonScripts/FileManGlobalDataParser.py | 20 +++--- .../PythonScripts/GenerateNameNumberPages.py | 2 +- Utilities/Dox/PythonScripts/ICRFileToJson.py | 8 +-- Utilities/Dox/PythonScripts/ICRParserTest.py | 2 +- .../InitCrossReferenceGenerator.py | 3 +- Utilities/Dox/PythonScripts/LogManager.py | 3 - .../PythonScripts/RequirementsJSONtoHTML.py | 4 +- .../PythonScripts/RequirementsXLStoJSON.py | 16 ++--- .../Dox/PythonScripts/UtilityFunctions.py | 4 +- .../Dox/PythonScripts/WebPageGenerator.py | 67 +++++++++---------- .../Dox/PythonScripts/ZWRGlobalParser.py | 5 +- 13 files changed, 69 insertions(+), 92 deletions(-) diff --git a/Utilities/Dox/PythonScripts/CallerGraphParser.py b/Utilities/Dox/PythonScripts/CallerGraphParser.py index 18a275967..8913bdc37 100755 --- a/Utilities/Dox/PythonScripts/CallerGraphParser.py +++ b/Utilities/Dox/PythonScripts/CallerGraphParser.py @@ -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 @@ -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): @@ -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 diff --git a/Utilities/Dox/PythonScripts/CrossReference.py b/Utilities/Dox/PythonScripts/CrossReference.py index 27a6ccdc1..9563271cf 100755 --- a/Utilities/Dox/PythonScripts/CrossReference.py +++ b/Utilities/Dox/PythonScripts/CrossReference.py @@ -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 @@ -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): @@ -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): @@ -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) @@ -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): @@ -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): @@ -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 @@ -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): diff --git a/Utilities/Dox/PythonScripts/FileManGlobalDataParser.py b/Utilities/Dox/PythonScripts/FileManGlobalDataParser.py index f411f9c58..a89f07fd5 100644 --- a/Utilities/Dox/PythonScripts/FileManGlobalDataParser.py +++ b/Utilities/Dox/PythonScripts/FileManGlobalDataParser.py @@ -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] @@ -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) @@ -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 @@ -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) diff --git a/Utilities/Dox/PythonScripts/GenerateNameNumberPages.py b/Utilities/Dox/PythonScripts/GenerateNameNumberPages.py index 22e2249c7..70e9f30d1 100644 --- a/Utilities/Dox/PythonScripts/GenerateNameNumberPages.py +++ b/Utilities/Dox/PythonScripts/GenerateNameNumberPages.py @@ -44,7 +44,7 @@ def generateListingPage(outDir, pageData, dataType): outputDataListTableHeader(output, dataType, pageData["headers"], pageData["headers"], []) output.write("") output.write("""
""") - output.write("

%s Data List

" % (dataType)) + output.write("

%s Data List

" % dataType) outputCustomDataTableHeader(output, pageData["headers"], dataType) output.write("\n") for object in pageData["records"]: diff --git a/Utilities/Dox/PythonScripts/ICRFileToJson.py b/Utilities/Dox/PythonScripts/ICRFileToJson.py index 8fdc6b03a..82b0fbfe3 100644 --- a/Utilities/Dox/PythonScripts/ICRFileToJson.py +++ b/Utilities/Dox/PythonScripts/ICRFileToJson.py @@ -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' @@ -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 @@ -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)) diff --git a/Utilities/Dox/PythonScripts/ICRParserTest.py b/Utilities/Dox/PythonScripts/ICRParserTest.py index c9de85a99..4e5eedff7 100644 --- a/Utilities/Dox/PythonScripts/ICRParserTest.py +++ b/Utilities/Dox/PythonScripts/ICRParserTest.py @@ -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"], diff --git a/Utilities/Dox/PythonScripts/InitCrossReferenceGenerator.py b/Utilities/Dox/PythonScripts/InitCrossReferenceGenerator.py index ee7810c04..087121bc8 100644 --- a/Utilities/Dox/PythonScripts/InitCrossReferenceGenerator.py +++ b/Utilities/Dox/PythonScripts/InitCrossReferenceGenerator.py @@ -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 @@ -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 diff --git a/Utilities/Dox/PythonScripts/LogManager.py b/Utilities/Dox/PythonScripts/LogManager.py index 355e1ed44..7f7ced6d7 100755 --- a/Utilities/Dox/PythonScripts/LogManager.py +++ b/Utilities/Dox/PythonScripts/LogManager.py @@ -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) diff --git a/Utilities/Dox/PythonScripts/RequirementsJSONtoHTML.py b/Utilities/Dox/PythonScripts/RequirementsJSONtoHTML.py index 2c7e3afe2..29f65b8f6 100644 --- a/Utilities/Dox/PythonScripts/RequirementsJSONtoHTML.py +++ b/Utilities/Dox/PythonScripts/RequirementsJSONtoHTML.py @@ -3,8 +3,6 @@ import json import argparse import os.path -import cgi -import sys from LogManager import logger from DataTableHtml import outputDataTableHeader, outputDataTableFooter @@ -155,7 +153,7 @@ def _generateRequirementsSummaryPageImpl(self, inputJson, listName, pkgName, isF for reqEntry in reqData: output.write("\n") if not isForAll: - reqSummary = self._convertReqEntryToSummaryInfo(reqEntry); + reqSummary = self._convertReqEntryToSummaryInfo(reqEntry) if not reqSummary in allReqs: allReqs.append(reqSummary) else: diff --git a/Utilities/Dox/PythonScripts/RequirementsXLStoJSON.py b/Utilities/Dox/PythonScripts/RequirementsXLStoJSON.py index c4b834088..5741a8f19 100644 --- a/Utilities/Dox/PythonScripts/RequirementsXLStoJSON.py +++ b/Utilities/Dox/PythonScripts/RequirementsXLStoJSON.py @@ -66,7 +66,7 @@ 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 @@ -74,7 +74,7 @@ def parseStringVal(value, index): 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(" [")] @@ -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']: @@ -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: @@ -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) @@ -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 diff --git a/Utilities/Dox/PythonScripts/UtilityFunctions.py b/Utilities/Dox/PythonScripts/UtilityFunctions.py index 5165142ce..51770e372 100644 --- a/Utilities/Dox/PythonScripts/UtilityFunctions.py +++ b/Utilities/Dox/PythonScripts/UtilityFunctions.py @@ -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 @@ -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 diff --git a/Utilities/Dox/PythonScripts/WebPageGenerator.py b/Utilities/Dox/PythonScripts/WebPageGenerator.py index 778384885..b8b924264 100755 --- a/Utilities/Dox/PythonScripts/WebPageGenerator.py +++ b/Utilities/Dox/PythonScripts/WebPageGenerator.py @@ -304,9 +304,9 @@ def writePDFCustomization(outputFile, titleList): outputFile.write("\n") @@ -324,7 +324,7 @@ def writePDFCustomization(outputFile, titleList): """ -ACCORDION = """ +ACCORDION = """