You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bitcoin/contrib/filter-lcov.py

25 lines
844 B

#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(description='Remove the coverage data from a tracefile for all files matching the pattern.')
parser.add_argument('pattern', help='the pattern of files to remove')
parser.add_argument('tracefile', help='the tracefile to remove the coverage data from')
parser.add_argument('outfile', help='filename for the output to be written to')
args = parser.parse_args()
tracefile = args.tracefile
pattern = args.pattern
outfile = args.outfile
in_remove = False
with open(tracefile, 'r') as f:
with open(outfile, 'w') as wf:
for line in f:
if line.startswith("SF:") and pattern in line:
in_remove = True
if not in_remove:
wf.write(line)
if line == 'end_of_record\n':
in_remove = False