def parseMetrics(ncssDb, invEntDict): timer = Timer("Parsing ncss measurements") timer.start() nrOfMeasurements=0 for line in open(ncssDb, "r"): if "Nr. " in line: continue if line.startswith("Average"): break ncssEnt = NCSSMetricEntity(line) if not ncssEnt.isKnownEntity(invEntDict): log.warn( "Unknown invokable entity "+\ ncssEnt.composeUniqName()) log.warn("line: "+line) continue uniqName = ncssEnt.composeUniqName() sLoc = SourceLocation("", "0", "0") generateMetrics("CC", ncssEnt.metricCC, uniqName, sLoc) generateMetrics("COM", ncssEnt.metricCOM, uniqName, sLoc) generateMetrics("LOC", ncssEnt.metricLOC, uniqName, sLoc) nrOfMeasurements += 1 timer.stop() timer.log(nrOfMeasurements)
def parseMethodTables( methodImplementationDBD, methodDefinitionDBD, \ classSelector, classDict, namespaceContainmentChecker,\ typedefDict,invokeableEntityDict, methodSourceDict): # build up a method cache # these caches are used by the RuleChecker to find out # whether the method should be generated. # TODO: use the method-dictionary to filter out generation requests # so that there is no longer a need for the low-level caches used below. dbdumpFile=open(methodDefinitionDBD, 'r') isImpl = False timer = Timer("Parsing method declarations") timer.start() nrOfItems = parseMethods( dbdumpFile, isImpl, \ classSelector, classDict, namespaceContainmentChecker,typedefDict,invokeableEntityDict) timer.stop() timer.log(nrOfItems) dbdumpFile.close() # check for methods that are immediately implemented dbdumpFile=open(methodImplementationDBD, 'r') isImpl = True timer = Timer("Parsing method definitions") timer.start() nrOfItems = parseMethods( dbdumpFile, isImpl, \ classSelector, classDict, namespaceContainmentChecker,\ typedefDict,invokeableEntityDict, methodSourceDict) timer.stop() timer.log(nrOfItems) dbdumpFile.close()
def parseFunctionTables(functionDBD, functionDefDBD, \ typedefDict, namespaceContainmentChecker, classSelector, \ invokeableEntityDict, methodSourceDict): dbdumpFile=open(functionDBD, 'r') isImpl = True timer = Timer("Parsing function declarations") timer.start() nrOfItems = parseFunctions(dbdumpFile, isImpl, typedefDict, namespaceContainmentChecker, classSelector, invokeableEntityDict, methodSourceDict) # temporarily also add to declarations to methodSourceDict timer.stop() timer.log(nrOfItems) dbdumpFile.close() dbdumpFile=open(functionDefDBD, 'r') isImpl = False timer = Timer("Parsing function definitions") timer.start() nrOfItems = parseFunctions(dbdumpFile, isImpl, typedefDict, namespaceContainmentChecker, classSelector, invokeableEntityDict, methodSourceDict) timer.stop() timer.log(nrOfItems) dbdumpFile.close()
def parseVCSMetrics(vcsDb, fileDict): """ reads in file change frequency metrics to FAMIX CDIF""" timer = Timer("Parsing VCS measurements") timer.start() nrOfMeasurements = 0 for line in open(vcsDb, "r"): cols = line.split(";") fileName = cols[0] cf = cols[1].strip() #print "VCS", fileName, cf if fileName in fileDict.list: sLoc = SourceLocation(fileName, "0", "0") common.famix.cdifWriter.generateMetrics("CF", cf, fileName, sLoc) else: log.warn(fileName + " not known to the file dict.") nrOfMeasurements += 1 timer.stop() timer.log(nrOfMeasurements)
def parseVCSMetrics(vcsDb,fileDict): """ reads in file change frequency metrics to FAMIX CDIF""" timer = Timer("Parsing VCS measurements") timer.start() nrOfMeasurements=0 for line in open(vcsDb, "r"): cols = line.split(";") fileName = cols[0] cf = cols[1].strip() #print "VCS", fileName, cf if fileName in fileDict.list: sLoc = SourceLocation(fileName, "0", "0") common.famix.cdifWriter.generateMetrics("CF", cf, fileName, sLoc) else: log.warn(fileName+" not known to the file dict.") nrOfMeasurements += 1 timer.stop() timer.log(nrOfMeasurements)
def parsePmcmetrics(pmcDb, invEntDict): from common.metrics import PmcMetricEntity timer = Timer("Parsing measurements") timer.start() nrOfMeasurements=0 for line in open(pmcDb, "r"): pmcEnt = PmcMetricEntity(line) if not pmcEnt.isKnownEntity(invEntDict): continue uniqName = pmcEnt.invEntRef.getUniqueName() sLoc = SourceLocation(pmcEnt.filename, pmcEnt.lineNr, pmcEnt.lineNr) common.famix.cdifWriter.generateMetrics("CC", pmcEnt.metricCC, uniqName, sLoc) common.famix.cdifWriter.generateMetrics("NOS", pmcEnt.metricNOS, uniqName, sLoc) #common.famix.cdifWriter.generateMetrics("LOC", pmcEnt.metricLOC, uniqName, sLoc) common.famix.cdifWriter.generateMetrics("LOC", pmcEnt.metricNOS, uniqName, sLoc) nrOfMeasurements += 1 timer.stop() timer.log(nrOfMeasurements)
# famix level 3 log.info("Entering famix Level 3") referencesDbLoc = dbLoc + ".references" DataReqs.checkfamixL3Reqs(sys.argv[1] + "/" + sys.argv[2]) # list of line numbers of the referencesDbLoc which are already # processed as accesses referenceLinesRecognizedAsAccesses = [] log.info("Parsing accesses ...") accessDict = AccessDictionary() timer = Timer("Parsing accesses") timer.start() nrOfItems = snavTableReader.parseAccess(referencesDbLoc, accessDict, invokeableEntityDict, attrDict, typedefDict, transInhDict, scope, referenceLinesRecognizedAsAccesses, output_file) timer.stop() timer.log(nrOfItems) log.info("Parsing invocations ...") timer = Timer("Parsing invocations") timer.start() nrOfItems = snavTableReader.parseInvocations(referencesDbLoc, accessDict, \ invokeableEntityDict, typedefDict, \ transIncludeDict, transInhDict, scope, \ referenceLinesRecognizedAsAccesses) timer.stop() timer.log(nrOfItems) log.info("Parsing macro uses ...") timer = Timer("Parsing macro uses") timer.start() nrOfItems = snavTableReader.parseMacroUses(referencesDbLoc,maDict)
# list of line numbers of the referencesDbLoc which are already # processed as accesses referenceLinesRecognizedAsAccesses = [] log.info("Parsing accesses ...") accessDict = AccessDictionary() timer = Timer("Parsing accesses") timer.start() nrOfItems = snavTableReader.parseAccess(referencesDbLoc, accessDict, invokeableEntityDict, attrDict, typedefDict, transInhDict, scope, referenceLinesRecognizedAsAccesses, output_file) timer.stop() timer.log(nrOfItems) log.info("Parsing invocations ...") timer = Timer("Parsing invocations") timer.start() nrOfItems = snavTableReader.parseInvocations(referencesDbLoc, accessDict, \ invokeableEntityDict, typedefDict, \ transIncludeDict, transInhDict, scope, \ referenceLinesRecognizedAsAccesses) timer.stop() timer.log(nrOfItems) log.info("Parsing macro uses ...") timer = Timer("Parsing macro uses") timer.start() nrOfItems = snavTableReader.parseMacroUses(referencesDbLoc, maDict)