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

Function collect_stats

tools/c_coverage/c_coverage_report.py:118–141  ·  view source on GitHub ↗
(files, fd, pattern)

Source from the content-addressed store, hash-verified

116
117
118def collect_stats(files, fd, pattern):
119 # TODO: Handle compressed callgrind files
120 line_regexs = [
121 re.compile(r"(?P<lineno>[0-9]+)(\s[0-9]+)+"),
122 re.compile(r"((jump)|(jcnd))=([0-9]+)\s(?P<lineno>[0-9]+)")
123 ]
124
125 current_file = None
126 current_function = None
127 for i, line in enumerate(fd):
128 if re.match("f[lie]=.+", line):
129 path = line.split('=', 2)[1].strip()
130 if os.path.exists(path) and re.search(pattern, path):
131 current_file = files.get_file(path)
132 else:
133 current_file = None
134 elif re.match("fn=.+", line):
135 current_function = line.split('=', 2)[1].strip()
136 elif current_file is not None:
137 for regex in line_regexs:
138 match = regex.match(line)
139 if match:
140 lineno = int(match.group('lineno'))
141 current_file.mark_line(lineno, current_function)
142
143
144if __name__ == '__main__':

Callers 1

Calls 6

stripMethod · 0.80
get_fileMethod · 0.80
mark_lineMethod · 0.80
compileMethod · 0.45
splitMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected