本文整理汇总了Python中coverage.parser.PythonParser._raw_parse方法的典型用法代码示例。如果您正苦于以下问题:Python PythonParser._raw_parse方法的具体用法?Python PythonParser._raw_parse怎么用?Python PythonParser._raw_parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coverage.parser.PythonParser
的用法示例。
在下文中一共展示了PythonParser._raw_parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: one_file
# 需要导入模块: from coverage.parser import PythonParser [as 别名]
# 或者: from coverage.parser.PythonParser import _raw_parse [as 别名]
def one_file(self, options, filename):
"""Process just one file."""
try:
text = get_python_source(filename)
bp = ByteParser(text, filename=filename)
except Exception as err:
print("%s" % (err,))
return
if options.dis:
print("Main code:")
self.disassemble(bp, histogram=options.histogram)
arcs = bp._all_arcs()
if options.chunks:# and not options.dis:
chunks = bp._all_chunks()
if options.recursive:
print("%6d: %s" % (len(chunks), filename))
else:
print("Chunks: %r" % chunks)
print("Arcs: %r" % sorted(arcs))
if options.source or options.tokens:
cp = PythonParser(filename=filename, exclude=r"no\s*cover")
cp.show_tokens = options.tokens
cp._raw_parse()
if options.source:
if options.chunks:
arc_width, arc_chars = self.arc_ascii_art(arcs)
else:
arc_width, arc_chars = 0, {}
exit_counts = cp.exit_counts()
for lineno, ltext in enumerate(cp.lines, start=1):
m0 = m1 = m2 = m3 = a = ' '
if lineno in cp.statement_starts:
m0 = '-'
exits = exit_counts.get(lineno, 0)
if exits > 1:
m1 = str(exits)
if lineno in cp.docstrings:
m2 = '"'
if lineno in cp.classdefs:
m2 = 'C'
if lineno in cp.excluded:
m3 = 'x'
a = arc_chars[lineno].ljust(arc_width)
print("%4d %s%s%s%s%s %s" %
(lineno, m0, m1, m2, m3, a, ltext)
)