2019-10-13 04:31:04 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
|
|
|
from coverage import CoverageData
|
|
|
|
|
|
|
|
|
|
|
|
def get_args():
|
|
|
|
parser = ArgumentParser()
|
|
|
|
parser.add_argument('coveragefile', metavar='FILENAME', help='Path to the .coverage file')
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
def fix_paths(coverage_file):
|
|
|
|
file_name = os.path.abspath(coverage_file)
|
|
|
|
base_path = os.path.dirname(file_name)
|
|
|
|
data = CoverageData()
|
|
|
|
data.read_file(file_name)
|
|
|
|
new_lines = {}
|
|
|
|
for fname, report in data._lines.items():
|
2019-10-18 16:23:01 +00:00
|
|
|
if fname.startswith('C:\\'):
|
|
|
|
# This is a Windows path, let's fudge it
|
|
|
|
fname = fname.replace('C:', '').replace('\\', '/')
|
2019-10-13 04:31:04 +00:00
|
|
|
new_fname = os.path.join(base_path, fname.split('openlp/openlp/')[-1])
|
|
|
|
new_lines[new_fname] = report
|
|
|
|
data._lines = new_lines
|
|
|
|
data.write_file(file_name)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
args = get_args()
|
|
|
|
fix_paths(args.coveragefile)
|