本文整理匯總了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)
)