Revert "Remove unused variable in shell script"
[bitcoinplatinum.git] / contrib / filter-lcov.py
blob299377d691155308875fb95fe5b7f49f9e8d50dc
1 #!/usr/bin/env python3
3 import argparse
5 parser = argparse.ArgumentParser(description='Remove the coverage data from a tracefile for all files matching the pattern.')
6 parser.add_argument('--pattern', '-p', action='append', help='the pattern of files to remove', required=True)
7 parser.add_argument('tracefile', help='the tracefile to remove the coverage data from')
8 parser.add_argument('outfile', help='filename for the output to be written to')
10 args = parser.parse_args()
11 tracefile = args.tracefile
12 pattern = args.pattern
13 outfile = args.outfile
15 in_remove = False
16 with open(tracefile, 'r') as f:
17 with open(outfile, 'w') as wf:
18 for line in f:
19 for p in pattern:
20 if line.startswith("SF:") and p in line:
21 in_remove = True
22 if not in_remove:
23 wf.write(line)
24 if line == 'end_of_record\n':
25 in_remove = False