當前位置: 首頁>>代碼示例>>Python>>正文


Python LongBow.buildRed方法代碼示例

本文整理匯總了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()
開發者ID:isolis,項目名稱:LongBow,代碼行數:59,代碼來源:NameReport.py

示例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))
開發者ID:PARC,項目名稱:LongBow,代碼行數:19,代碼來源:StyleReport.py


注:本文中的LongBow.buildRed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。