MCPcopy Create free account
hub / github.com/numpy/numpy / SourceFile

Class SourceFile

tools/c_coverage/c_coverage_report.py:45–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44
45class SourceFile:
46 def __init__(self, path):
47 self.path = path
48 self.lines = {}
49
50 def mark_line(self, lineno, as_func=None):
51 line = self.lines.setdefault(lineno, set())
52 if as_func is not None:
53 as_func = as_func.split("'", 1)[0]
54 line.add(as_func)
55
56 def write_text(self, fd):
57 source = open(self.path, "r")
58 for i, line in enumerate(source):
59 if i + 1 in self.lines:
60 fd.write("> ")
61 else:
62 fd.write("! ")
63 fd.write(line)
64 source.close()
65
66 def write_html(self, fd):
67 source = open(self.path, 'r')
68 code = source.read()
69 lexer = CLexer()
70 formatter = FunctionHtmlFormatter(
71 self.lines,
72 full=True,
73 linenos='inline')
74 fd.write(highlight(code, lexer, formatter))
75 source.close()
76
77
78class SourceFiles:

Callers 1

get_fileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected