def gradeAndPrint(targets, exemplarCommand, exemplarConfig, problemsOnly=False, prefix=""): complianceList = [] problemList = [] for target in targets: try: complianceList.append( SyntaxCompliance(target, exemplarCommand, exemplarConfig).check()) except: problemList.append(target) pass complianceList = sorted(complianceList, key=lambda k: k.getFileName()) if problemsOnly: complianceList = filter(lambda entry: entry.getScore() < 100, complianceList) distribution = [99, 90] textSummary(distribution, complianceList, prefix) for target in problemList: print LongBow.buildRed("%s%s could not be evaluated" % (prefix, target))
def gradeAndPrint(targets, problemsOnly=False, printPrefix=""): if len(targets) < 1: print "No Files To Grade" return distribution = [99, 90] maxFileNameLength = max(max(map(lambda target: len(target), targets)), len("File Name")) moduleConformanceSet = ModuleSetConformanceContainer() headers = getConformanceHeaders() pformat = '{prefix}{:<{maxFileNameLength}}' nformat = pformat for header in headers: nformat = nformat + '{:>15}' print nformat.format('File Name', *headers, prefix=printPrefix, maxFileNameLength=maxFileNameLength) for target in targets: module = Module(target) if module.isTestSourceName(): continue fileNamePrefix = module.getModuleName() path = module.getModulePath() try: moduleConformance = computeModuleConformance(path, fileNamePrefix) if not moduleConformance.processModule(): pass else: moduleConformanceSet.addConformanceContainer(moduleConformance) scores = moduleConformance.getScores() minScore = 100.0 for key in scores: score = scores[key] if score < minScore: minScore = score scores[key] = '%3.1f'%score if problemsOnly and minScore == 100.0: continue printVals=[] for hval in headers: score = 'N/A' if hval in scores: score = scores[hval] printVals.append(score) line = nformat.format(target, *printVals, prefix=printPrefix, maxFileNameLength=maxFileNameLength) LongBow.scorePrinter(distribution, minScore, line) except NoObjectFileException as e: eformat = pformat + "Could Not Grade: No .o file found for file" line = eformat.format(target, prefix=printPrefix, maxFileNameLength=maxFileNameLength, msg=e) print LongBow.buildRed(line) pass except Exception as e: eformat = pformat + "Could Not Grade: {msg}" line = eformat.format(target, prefix=printPrefix, maxFileNameLength=maxFileNameLength, msg=e) print LongBow.buildRed(line) pass moduleConformanceSet.analyzeConformance()
def gradeAndPrint(targets, exemplarCommand, exemplarConfig, problemsOnly=False, prefix=""): complianceList = [] problemList = [] for target in targets: try: complianceList.append(SyntaxCompliance(target, exemplarCommand, exemplarConfig).check()) except: problemList.append(target) pass complianceList = sorted(complianceList, key=lambda k: k.getFileName()) if problemsOnly: complianceList = filter(lambda entry: entry.getScore() < 100, complianceList) distribution=[99,90] textSummary(distribution, complianceList, prefix) for target in problemList: print LongBow.buildRed("%s%s could not be evaluated" % (prefix, target))
def gradeAndPrint(targets, objectDirs, problemsOnly=False, printPrefix=""): if len(targets) < 1: print "No Files To Grade" return distribution = [99, 90] maxFileNameLength = max(max(map(lambda target: len(target), targets)), len("File Name")) moduleConformanceSet = ModuleSetConformanceContainer() headers = getConformanceHeaders() pformat = '{prefix}{:<{maxFileNameLength}}' nformat = pformat for header in headers: nformat = nformat + '{:>15}' print nformat.format('File Name', *headers, prefix=printPrefix, maxFileNameLength=maxFileNameLength) for target in targets: module = Module(target, objectDirs) if module.isTestSourceName(): continue fileNamePrefix = module.getModuleName() path = module.getModulePath() try: moduleConformance = computeModuleConformance(module) if not moduleConformance.processModule(): pass else: moduleConformanceSet.addConformanceContainer(moduleConformance) scores = moduleConformance.getScores() minScore = 100.0 for key in scores: score = scores[key] if score < minScore: minScore = score scores[key] = '%3.1f' % score if problemsOnly and minScore == 100.0: continue printVals = [] for hval in headers: score = 'N/A' if hval in scores: score = scores[hval] printVals.append(score) line = nformat.format(target, *printVals, prefix=printPrefix, maxFileNameLength=maxFileNameLength) LongBow.scorePrinter(distribution, minScore, line) except NoObjectFileException as e: eformat = pformat + "Could Not Grade: No .o file found for file" line = eformat.format(target, prefix=printPrefix, maxFileNameLength=maxFileNameLength, msg=e) print LongBow.buildRed(line) pass except Exception as e: eformat = pformat + "Could Not Grade: {msg}" line = eformat.format(target, prefix=printPrefix, maxFileNameLength=maxFileNameLength, msg=e) print LongBow.buildRed(line) pass moduleConformanceSet.analyzeConformance()