def parse(cDb, mtdSrcDict, mtdpfDict, type): """ Parse control structure information and write to cdif""" ctrlDict = CtrlStructCountDictionary.CtrlStructCountDictionary() # mtdpfDict = MethodsPerFileDictionary(mtdSrcDict) for line in open(cDb, "r"): splitted = line.split(":") srcFile = splitted[0] lineNr = int(splitted[1]) mtd, loc = mtdpfDict.getEnclosing(srcFile, lineNr) if mtd: ctrlDict.inc(mtd) else: log.warn("Failed to find owner method of cs: " + srcFile + " " + str(lineNr)) for mtd, val in ctrlDict.dict.iteritems(): src = mtdSrcDict.dict[mtd][0].split(":") sloc = SourceLocation(src[0], src[1], str(int(src[1]) + 1)) generateMetrics(type, str(val), mtd, sloc)
def parse(cDb, mtdSrcDict, mtdpfDict, type): """ Parse control structure information and write to cdif""" ctrlDict = CtrlStructCountDictionary.CtrlStructCountDictionary() #mtdpfDict = MethodsPerFileDictionary(mtdSrcDict) for line in open(cDb, 'r'): splitted = line.split(":") srcFile = splitted[0] lineNr = int(splitted[1]) mtd, loc = mtdpfDict.getEnclosing(srcFile, lineNr) if mtd: ctrlDict.inc(mtd) else: log.warn("Failed to find owner method of cs: " + srcFile + " " + str(lineNr)) for mtd, val in ctrlDict.dict.iteritems(): src = mtdSrcDict.dict[mtd][0].split(":") sloc = SourceLocation(src[0], src[1], str(int(src[1]) + 1)) generateMetrics(type, str(val), mtd, sloc)
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)