当前位置: 首页>>代码示例>>Python>>正文


Python LongBow类代码示例

本文整理汇总了Python中LongBow的典型用法代码示例。如果您正苦于以下问题:Python LongBow类的具体用法?Python LongBow怎么用?Python LongBow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LongBow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: textFunctionResult

def textFunctionResult(file, function, maxFileNameLength, maxFunctionNameLength):
	score = computeComplexityScore(function.cyclomatic_complexity)
	format = "%-" + str(maxFileNameLength) + "s %-" + str(maxFunctionNameLength) + "s %6d %2d %6.2f"
	string = format % (file.filename, function.name, function.start_line, function.cyclomatic_complexity, score)

	LongBow.scorePrinter([90, 80], score, string)
	return function.cyclomatic_complexity
开发者ID:isolis,项目名称:LongBow,代码行数:7,代码来源:longbow-complexity-report.py

示例2: textFileVocabulary

def textFileVocabulary(file, maxFileNameLength, printFormat=""):
	score = computeVocabularyScore(file.average_CCN)
	if printFormat == "":
		printFormat = "%-" + str(maxFileNameLength) + "s %6.2f %6.2f"
	string =  printFormat % (file.filename, file.average_token, score)
	LongBow.scorePrinter([90, 80], score, string)
	return
开发者ID:isolis,项目名称:LongBow,代码行数:7,代码来源:VocabularyReport.py

示例3: textSummary

def textSummary(args, filesAndTests, gCovResults, prefix=""):

    summary = GCov.computeSummary(filesAndTests, gCovResults)

    if not args.includeTestSources:
        summary = GCovSummary.removeTestSourceFiles(summary)

    if len(summary) == 0:
        return

    if args.explain:
        pp = pprint.PrettyPrinter(indent=2, width=150)
        pp.pprint(summary)

    maximumFileLength = max(map(lambda entry: len(entry), summary))

    format = "%s%-" + str(maximumFileLength) + "s %6s"
    print format % (prefix, "File Path", "Score")

    format = "%s%-" + str(maximumFileLength) + "s %6.2f"
    for testedFile in sorted(summary.keys()):
        string = format % (prefix, testedFile, summary[testedFile]["coverage"])
        if summary[testedFile]["direct"] == "indirect":
            ANSITerm.printColorized("magenta", string)
        else:
            LongBow.scorePrinter(eval(args.distribution), summary[testedFile]["coverage"], string)

    return
开发者ID:PARC,项目名称:LongBow,代码行数:28,代码来源:CoverageReport.py

示例4: textScore

def textScore(distribution, report, maxFileNameLength, prefix=""):
    '''

    '''
    format = "%s%-*s %6d %6d %6.2f"
    string = format % (prefix, maxFileNameLength, report["fileName"], report["totalLines"], report["nonCompliantLines"], report["score"])
    LongBow.scorePrinter(distribution, report["score"], string)
    return
开发者ID:PARC,项目名称:LongBow,代码行数:8,代码来源:StyleReport.py

示例5: csvSummary

def csvSummary(distribution, documentation):
        formatString ="documentation,%s,%d,%d,%.2f%%"
        for entry in documentation:
            badLines = len(documentation[entry])
            totalLines =  LongBow.countLines(entry)
            score = float(totalLines - badLines) / float(totalLines) * 100.0
            LongBow.scorePrinter(distribution, score, formatString % (entry, totalLines, badLines, score))
        return
开发者ID:PARC,项目名称:LongBow,代码行数:8,代码来源:longbow-doxygen-report.py

示例6: csvAverage

def csvAverage(args, filesAndTests, gcovResults):
    summary = GCov.computeSummary(filesAndTests, gcovResults)

    if not args.includeTestSources:
        summary = GCovSummary.removeTestSourceFiles(summary)

    score = GCovSummary.averageCoverage(summary)

    LongBow.scorePrinter(eval(args.distribution), score, "%.2f" % (score))
    return
开发者ID:PARC,项目名称:LongBow,代码行数:10,代码来源:CoverageReport.py

示例7: csvSummary

def csvSummary(args, filesAndTests, gCovResults):
    summary = GCov.computeSummary(filesAndTests, gCovResults)

    if not args.includeTestSources:
        summary = GCovSummary.removeTestSourceFiles(summary)

    if len(summary) > 0:
        for testedFile in sorted(summary.keys()):
            outputString = "%s,%.2f" % (testedFile, summary[testedFile]["coverage"])
            LongBow.scorePrinter(eval(args.distribution), summary[testedFile]["coverage"], outputString)

    return
开发者ID:PARC,项目名称:LongBow,代码行数:12,代码来源:CoverageReport.py

示例8: textualSummary

def textualSummary(distribution, documentation):
    maxWidth = 0
    for entry in documentation:
        if len(entry) > maxWidth:
            maxWidth = len(entry)

    formatString ="%-" + str(maxWidth) + "s %8d %8d   %.2f%%"
    for entry in documentation:
        badLines = len(documentation[entry])
        totalLines =  LongBow.countLines(entry)
        score = float(totalLines - badLines) / float(totalLines) * 100.0
        LongBow.scorePrinter(distribution, score, formatString % (entry, totalLines, badLines, score))
    return
开发者ID:PARC,项目名称:LongBow,代码行数:13,代码来源:longbow-doxygen-report.py

示例9: textualAverage

def textualAverage(distribution, documentation, format):
    sum = 0.0

    for entry in documentation:
        badLines = len(documentation[entry])
        totalLines =  LongBow.countLines(entry)
        score = float(totalLines - badLines) / float(totalLines) * 100.0
        sum = sum + score

    if len(documentation) == 0:
        averageScore = 100.0
    else:
        averageScore = sum / float(len(documentation))

    LongBow.scorePrinter(distribution, averageScore, format % averageScore)
开发者ID:PARC,项目名称:LongBow,代码行数:15,代码来源:longbow-doxygen-report.py

示例10: gradeAndPrint

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,代码行数:17,代码来源:StyleReport.py

示例11: tuplesListToPrettyText

def tuplesListToPrettyText(points, distribution = [99, 90]):
    '''
    Convert a list of tuples -- data points -- to a list of colorized strings based
    on the provided distribution.
    '''
    lines = []
    for point in points:
        line = ""
        for i in range(len(point) - 1):
            line = line + str(point[i]) + " "
        line = line + str(point[-1])
        lines.append(LongBow.scoreBuilder(distribution, point[-1], line))
    return lines
开发者ID:isolis,项目名称:LongBow,代码行数:13,代码来源:NameReport.py

示例12: gradeAndPrint

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,代码行数:57,代码来源:NameReport.py

示例13: gradeAndPrint

def gradeAndPrint(targets, testDirs=[], problemsOnly=False, prefix=""):
    filesAndTests = getFilesAndTests(targets, testDirs)
    newGCovResults = map(lambda fileAndTestFile: GCov.getCoverage(fileAndTestFile[1]), filesAndTests)

    summarys = GCov.computeSummary(filesAndTests, newGCovResults)
    if len(summarys) < 1:
        print "%sNo GCov Results - Please be sure to run 'make check' first" % prefix
        return False
    summarys = GCovSummary.removeTestSourceFiles(summarys)

    paths = summarys.keys()
    if problemsOnly:
        paths = filter(lambda key: summarys[key]["coverage"] < 100, paths)

    distribution=[99,90]
    maximumFileLength = max(map(lambda entry: len(os.path.relpath(entry)), paths))
    format = "%s%-" + str(maximumFileLength) + "s %6s"
    print format % (prefix, "File Path", "Score")
    format = "%s%-" + str(maximumFileLength) + "s %6.2f"
    for path in sorted(paths):
        string = format % (prefix, os.path.relpath(path), summarys[path]["coverage"])
        LongBow.scorePrinter(distribution, summarys[path]["coverage"], string)

    return True
开发者ID:PARC,项目名称:LongBow,代码行数:24,代码来源:CoverageReport.py

示例14: csvFileComplexity

def csvFileComplexity(file):
	score = computeComplexityScore(file.average_CCN)
	string = "complexity,%s,,,%.2f,%.2f" % (file.filename, file.average_CCN, score)
	LongBow.scorePrinter([90, 80], score, string)
	return
开发者ID:isolis,项目名称:LongBow,代码行数:5,代码来源:longbow-complexity-report.py

示例15: csvFunctionResult

def csvFunctionResult(file, function):
	score = computeComplexityScore(function.cyclomatic_complexity)
	string = "complexity,%s,%s,%d,%d,%.2f" % (file.filename, function.name, function.start_line, function.cyclomatic_complexity, score)

	LongBow.scorePrinter([90, 80], score, string)
	return function.cyclomatic_complexity
开发者ID:isolis,项目名称:LongBow,代码行数:6,代码来源:longbow-complexity-report.py


注:本文中的LongBow类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。