本文整理汇总了Python中LongBow.buildRed方法的典型用法代码示例。如果您正苦于以下问题:Python LongBow.buildRed方法的具体用法?Python LongBow.buildRed怎么用?Python LongBow.buildRed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LongBow
的用法示例。
在下文中一共展示了LongBow.buildRed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gradeAndPrint
# 需要导入模块: import LongBow [as 别名]
# 或者: from LongBow import buildRed [as 别名]
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()
示例2: gradeAndPrint
# 需要导入模块: import LongBow [as 别名]
# 或者: from LongBow import buildRed [as 别名]
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))