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

Class SourceFiles

tools/c_coverage/c_coverage_report.py:76–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75
76class SourceFiles:
77 def __init__(self):
78 self.files = {}
79 self.prefix = None
80
81 def get_file(self, path):
82 if path not in self.files:
83 self.files[path] = SourceFile(path)
84 if self.prefix is None:
85 self.prefix = path
86 else:
87 self.prefix = os.path.commonpath([self.prefix, path])
88 return self.files[path]
89
90 def clean_path(self, path):
91 path = path[len(self.prefix):]
92 return re.sub(r"[^A-Za-z0-9\.]", '_', path)
93
94 def write_text(self, root):
95 for path, source in self.files.items():
96 with open(os.path.join(root, self.clean_path(path)), "w") as fd:
97 source.write_text(fd)
98
99 def write_html(self, root):
100 for path, source in self.files.items():
101 with open(
102 os.path.join(root, self.clean_path(path) + ".html"), "w"
103 ) as fd:
104 source.write_html(fd)
105
106 with open(os.path.join(root, 'index.html'), 'w') as fd:
107 fd.write("<html>")
108 paths = sorted(self.files.keys())
109 for path in paths:
110 href = self.clean_path(path)
111 label = escape(path[len(self.prefix):])
112 fd.write(f'<p><a href="{href}.html">{label}</a></p>')
113 fd.write("</html>")
114
115
116def collect_stats(files, fd, pattern):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…