Commit 9061bb33 authored by Jan Kiene's avatar Jan Kiene
Browse files

add csv writeout to create_report_pages.py

parent 7e4678ed
Loading
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ COLUMNS = ["testcase", "MLD", "MAXIMUM ABS DIFF"]

def create_subpage(
    html_out,
    csv_out,
    csv_current: str,
    csv_previous: str,
    id_current: int,
@@ -69,6 +70,7 @@ def create_subpage(
    merged_reports = merge_and_cleanup_mld_reports(
        csv_current, csv_previous, id_current, id_previous
    )
    write_out_csv(merged_reports, merged_reports[0].keys(), csv_out)
    table_body = "\n".join(
        tr_from_row(row, id_current, id_previous) for row in merged_reports
    )
@@ -82,6 +84,14 @@ def create_subpage(
        f.write(new_subpage)


def write_out_csv(data, col_names, outfile):
    with open(outfile, "w") as f:
        writer = csv.DictWriter(f, col_names, delimiter=";")
        writer.writeheader()
        for row in data:
            writer.writerow(row)


def tr_from_row(row, id_current, id_previous):
    tr = list()
    for c in COLUMNS:
@@ -167,6 +177,7 @@ def merge_tables(tbl1, tbl2, suffix1, suffix2, merge_key, other_keys):
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("html_out")
    parser.add_argument("csv_out")
    parser.add_argument("csv_current")
    parser.add_argument("csv_previous")
    parser.add_argument("id_current", type=int)
@@ -176,6 +187,7 @@ if __name__ == "__main__":

    create_subpage(
        args.html_out,
        args.csv_out,
        args.csv_current,
        args.csv_previous,
        args.id_current,