MCPcopy Index your code
hub / github.com/numpy/numpy / SourceFile

Class SourceFile

tools/c_coverage/c_coverage_report.py:45–73  ·  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 with open(self.path, "r") as source:
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
65 def write_html(self, fd):
66 with open(self.path, 'r') as source:
67 code = source.read()
68 lexer = CLexer()
69 formatter = FunctionHtmlFormatter(
70 self.lines,
71 full=True,
72 linenos='inline')
73 fd.write(highlight(code, lexer, formatter))
74
75
76class SourceFiles:

Callers 1

get_fileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…