From db3209b759536c90a3ccdd83874ba0640c62cfa2 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 11 Oct 2019 14:43:21 -0700 Subject: [PATCH] Add the fixpaths.py script for fixing the combined coverage report paths --- Dockerfile.debian | 2 ++ fixpaths.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 fixpaths.py diff --git a/Dockerfile.debian b/Dockerfile.debian index 3f082c2..9f16162 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -8,3 +8,5 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive \ python3-websockets python3-webob python3-waitress python3-requests python3-pymediainfo \ python3-qtawesome python3-opengl python3-appdirs python3-vlc python3-zeroconf python3-pip \ python3-flake8 flake8 mediainfo mupdf-tools xvfb +ADD fixpaths.py /usr/bin/fixpaths +RUN chmod a+x /usr/bin/fixpaths diff --git a/fixpaths.py b/fixpaths.py new file mode 100755 index 0000000..d4180d3 --- /dev/null +++ b/fixpaths.py @@ -0,0 +1,29 @@ +#!/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(): + 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)