2017-06-07 02:26:56 +02:00
|
|
|
#!/usr/bin/env python3
|
2020-12-31 09:48:25 +01:00
|
|
|
# Copyright (c) 2017-2020 The Bitcoin Core developers
|
2019-12-07 17:14:40 +01:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2017-06-07 02:26:56 +02:00
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Remove the coverage data from a tracefile for all files matching the pattern.')
|
2017-06-09 03:15:55 +02:00
|
|
|
parser.add_argument('--pattern', '-p', action='append', help='the pattern of files to remove', required=True)
|
2017-06-07 02:26:56 +02:00
|
|
|
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
|
2018-06-12 17:49:20 +02:00
|
|
|
with open(tracefile, 'r', encoding="utf8") as f:
|
|
|
|
with open(outfile, 'w', encoding="utf8") as wf:
|
2017-06-07 02:26:56 +02:00
|
|
|
for line in f:
|
2017-06-09 03:15:55 +02:00
|
|
|
for p in pattern:
|
|
|
|
if line.startswith("SF:") and p in line:
|
|
|
|
in_remove = True
|
2017-06-07 02:26:56 +02:00
|
|
|
if not in_remove:
|
|
|
|
wf.write(line)
|
|
|
|
if line == 'end_of_record\n':
|
|
|
|
in_remove = False
|