Changeset View
Changeset View
Standalone View
Standalone View
contrib/filter-lcov.py
Show All 10 Lines | |||||
parser.add_argument('outfile', help='filename for the output to be written to') | parser.add_argument('outfile', help='filename for the output to be written to') | ||||
args = parser.parse_args() | args = parser.parse_args() | ||||
tracefile = args.tracefile | tracefile = args.tracefile | ||||
pattern = args.pattern | pattern = args.pattern | ||||
outfile = args.outfile | outfile = args.outfile | ||||
in_remove = False | in_remove = False | ||||
with open(tracefile, 'r') as f: | with open(tracefile, 'r', encoding="utf8") as f: | ||||
with open(outfile, 'w') as wf: | with open(outfile, 'w', encoding="utf8") as wf: | ||||
for line in f: | for line in f: | ||||
for p in pattern: | for p in pattern: | ||||
if line.startswith("SF:") and p in line: | if line.startswith("SF:") and p in line: | ||||
in_remove = True | in_remove = True | ||||
if not in_remove: | if not in_remove: | ||||
wf.write(line) | wf.write(line) | ||||
if line == 'end_of_record\n': | if line == 'end_of_record\n': | ||||
in_remove = False | in_remove = False |