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


Python PythonParser.arcs方法代码示例

本文整理汇总了Python中coverage.parser.PythonParser.arcs方法的典型用法代码示例。如果您正苦于以下问题:Python PythonParser.arcs方法的具体用法?Python PythonParser.arcs怎么用?Python PythonParser.arcs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coverage.parser.PythonParser的用法示例。


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

示例1: compare_alternatives

# 需要导入模块: from coverage.parser import PythonParser [as 别名]
# 或者: from coverage.parser.PythonParser import arcs [as 别名]
def compare_alternatives(source):
    all_all_arcs = collections.defaultdict(list)
    for i, alternate_source in enumerate(async_alternatives(source)):
        parser = PythonParser(alternate_source)
        arcs = parser.arcs()
        all_all_arcs[tuple(arcs)].append((i, alternate_source))

    return len(all_all_arcs)
开发者ID:enquos,项目名称:coveragepy,代码行数:10,代码来源:genpy.py

示例2: print

# 需要导入模块: from coverage.parser import PythonParser [as 别名]
# 或者: from coverage.parser.PythonParser import arcs [as 别名]
"""Parse every Python file in a tree."""

import os
import sys

from coverage.misc import CoverageException
from coverage.parser import PythonParser

for root, dirnames, filenames in os.walk(sys.argv[1]):
    for filename in filenames:
        if filename.endswith(".py"):
            filename = os.path.join(root, filename)
            print(":: {}".format(filename))
            try:
                par = PythonParser(filename=filename)
                par.parse_source()
                par.arcs()
            except Exception as exc:
                print("  ** {}".format(exc))
开发者ID:d-b-w,项目名称:coveragepy,代码行数:21,代码来源:parse_all.py

示例3: one_file

# 需要导入模块: from coverage.parser import PythonParser [as 别名]
# 或者: from coverage.parser.PythonParser import arcs [as 别名]
    def one_file(self, options, filename):
        """Process just one file."""
        # `filename` can have a line number suffix. In that case, extract those
        # lines, dedent them, and use that.  This is for trying test cases
        # embedded in the test files.
        match = re.search(r"^(.*):(\d+)-(\d+)$", filename)
        if match:
            filename, start, end = match.groups()
            start, end = int(start), int(end)
        else:
            start = end = None

        try:
            text = get_python_source(filename)
            if start is not None:
                lines = text.splitlines(True)
                text = textwrap.dedent("".join(lines[start-1:end]).replace("\\\\", "\\"))
            pyparser = PythonParser(text, filename=filename, exclude=r"no\s*cover")
            pyparser.parse_source()
        except Exception as err:
            print("%s" % (err,))
            return

        if options.dis:
            print("Main code:")
            self.disassemble(pyparser.byte_parser, histogram=options.histogram)

        arcs = pyparser.arcs()

        if options.source or options.tokens:
            pyparser.show_tokens = options.tokens
            pyparser.parse_source()

            if options.source:
                arc_chars = self.arc_ascii_art(arcs)
                if arc_chars:
                    arc_width = max(len(a) for a in arc_chars.values())

                exit_counts = pyparser.exit_counts()

                for lineno, ltext in enumerate(pyparser.lines, start=1):
                    marks = [' ', ' ', ' ', ' ', ' ']
                    a = ' '
                    if lineno in pyparser.raw_statements:
                        marks[0] = '-'
                    if lineno in pyparser.statements:
                        marks[1] = '='
                    exits = exit_counts.get(lineno, 0)
                    if exits > 1:
                        marks[2] = str(exits)
                    if lineno in pyparser.raw_docstrings:
                        marks[3] = '"'
                    if lineno in pyparser.raw_classdefs:
                        marks[3] = 'C'
                    if lineno in pyparser.raw_excluded:
                        marks[4] = 'x'

                    if arc_chars:
                        a = arc_chars[lineno].ljust(arc_width)
                    else:
                        a = ""

                    print("%4d %s%s %s" % (lineno, "".join(marks), a, ltext))
开发者ID:d-b-w,项目名称:coveragepy,代码行数:65,代码来源:parser.py


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