mirror of
https://gitlab.com/openlp/runners.git
synced 2024-12-22 11:22:48 +00:00
Coverage now uses a SQLite database, so it's much easier to edit the data directly
This commit is contained in:
parent
5371d01a99
commit
6d56fc39ec
27
fixpaths.py
27
fixpaths.py
@ -1,9 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
from coverage import CoverageData
|
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
@ -12,19 +11,21 @@ def get_args():
|
|||||||
|
|
||||||
|
|
||||||
def fix_paths(coverage_file):
|
def fix_paths(coverage_file):
|
||||||
|
# Get the file name, and extrapolate the base path
|
||||||
file_name = os.path.abspath(coverage_file)
|
file_name = os.path.abspath(coverage_file)
|
||||||
base_path = os.path.dirname(file_name)
|
base_path = os.path.dirname(file_name)
|
||||||
data = CoverageData()
|
# Open a connection to the SQLite database
|
||||||
data.read_file(file_name)
|
db = sqlite3.connect(file_name)
|
||||||
new_lines = {}
|
cursor = db.cursor()
|
||||||
for fname, report in data._lines.items():
|
# Get all the files in the database and update their filenames
|
||||||
if fname.startswith('C:\\'):
|
cursor.execute('SELECT id, path FROM file')
|
||||||
# This is a Windows path, let's fudge it
|
new_files = []
|
||||||
fname = fname.replace('C:', '').replace('\\', '/')
|
for row in cursor.fetchall():
|
||||||
new_fname = os.path.join(base_path, fname.split('openlp/openlp/')[-1])
|
new_files.append((os.path.join(base_path, row[1].split('openlp/openlp/')[-1]), row[0]))
|
||||||
new_lines[new_fname] = report
|
cursor.executemany('UPDATE file SET path = ? WHERE id = ?', new_files)
|
||||||
data._lines = new_lines
|
db.commit()
|
||||||
data.write_file(file_name)
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user