To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit ec53ee16 authored by scmalte's avatar scmalte
Browse files

revise.py: added columns to CSV export

parent 371bf2d5
...@@ -115,16 +115,42 @@ def add_average_percentage_column(doc): ...@@ -115,16 +115,42 @@ def add_average_percentage_column(doc):
row.insert(2, td) row.insert(2, td)
def write_result_table_to_csv_file(doc, csv_file): def write_result_table_to_csv_file(doc, csv_file):
# E.g. 12-345-678 (77%)
text_pattern = r"([\d-]+) \((\d+)%\)"
with open(csv_file, "w") as csv_fh: with open(csv_file, "w") as csv_fh:
rows = doc.find_all("tr") rows = doc.find_all("tr")
column_heads = [th.get_text().strip() for th in rows[0].find_all("th")] # column_heads = [th.get_text().strip() for th in rows[0].find_all("th")]
column_heads = [
"Id-1", "Percentage-1",
"Id-2", "Percentage-2",
"Percentage-Avg",
"Lines",
"Match-File"
]
csv_fh.write(",".join(column_heads)) csv_fh.write(",".join(column_heads))
csv_fh.write("\n") csv_fh.write("\n")
for row in rows[1:]: for row in rows[1:]:
for td in row.find_all("td"): for td in row.find_all("td"):
col_data = [td.get_text().strip() for td in row.find_all("td")] tds = [td for td in row.find_all("td")]
tds_text = [td.get_text().strip() for td in tds]
file1_match = re.search(text_pattern, tds_text[0])
file2_match = re.search(text_pattern, tds_text[1])
col_data = [
file1_match.group(1),
file1_match.group(2),
file2_match.group(1),
file2_match.group(2),
tds_text[2],
tds_text[3],
tds[0].a["href"]
]
csv_fh.write(",".join(col_data)) csv_fh.write(",".join(col_data))
csv_fh.write("\n") csv_fh.write("\n")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment