mirror of
https://gitlab.com/openlp/runners.git
synced 2024-12-22 11:22:48 +00:00
Merge branch 'fix-coverage-data' into 'master'
Coverage now uses a SQLite database, so it's much easier to edit the data directly See merge request openlp/runners!17
This commit is contained in:
commit
4c32a79094
27
fixpaths.py
27
fixpaths.py
@ -1,9 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
import sqlite3
|
||||
import os
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from coverage import CoverageData
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = ArgumentParser()
|
||||
@ -12,19 +11,21 @@ def get_args():
|
||||
|
||||
|
||||
def fix_paths(coverage_file):
|
||||
# Get the file name, and extrapolate the base path
|
||||
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)
|
||||
# Open a connection to the SQLite database
|
||||
db = sqlite3.connect(file_name)
|
||||
cursor = db.cursor()
|
||||
# Get all the files in the database and update their filenames
|
||||
cursor.execute('SELECT id, path FROM file')
|
||||
new_files = []
|
||||
for row in cursor.fetchall():
|
||||
new_files.append((os.path.join(base_path, row[1].split('openlp/openlp/')[-1]), row[0]))
|
||||
cursor.executemany('UPDATE file SET path = ? WHERE id = ?', new_files)
|
||||
db.commit()
|
||||
cursor.close()
|
||||
db.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user