mirror of
https://gitlab.com/openlp/runners.git
synced 2024-12-22 19:32:48 +00:00
33 lines
934 B
Python
Executable File
33 lines
934 B
Python
Executable File
#!/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():
|
|
if fname.startswith('C:\\'):
|
|
# This is a Windows path, let's fudge it
|
|
fname = fname.replace('C:', '').replace('\\', '/')
|
|
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)
|