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.

filter-lcov.py 916B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python3
  2. import argparse
  3. parser = argparse.ArgumentParser(description='Remove the coverage data from a tracefile for all files matching the pattern.')
  4. parser.add_argument('--pattern', '-p', action='append', help='the pattern of files to remove', required=True)
  5. parser.add_argument('tracefile', help='the tracefile to remove the coverage data from')
  6. parser.add_argument('outfile', help='filename for the output to be written to')
  7. args = parser.parse_args()
  8. tracefile = args.tracefile
  9. pattern = args.pattern
  10. outfile = args.outfile
  11. in_remove = False
  12. with open(tracefile, 'r') as f:
  13. with open(outfile, 'w') as wf:
  14. for line in f:
  15. for p in pattern:
  16. if line.startswith("SF:") and p in line:
  17. in_remove = True
  18. if not in_remove:
  19. wf.write(line)
  20. if line == 'end_of_record\n':
  21. in_remove = False