aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/generator_tables.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2020-05-27 12:57:58 +0200
committerTibor Frank <tifrank@cisco.com>2020-05-28 09:23:55 +0000
commit836cdd8930dd7383d5c59a4ae407864a1e03040f (patch)
tree9f035a944ebf3cec99f1aa602fea858a4b9bf2a6 /resources/tools/presentation/generator_tables.py
parentcb0188995fc92673b0d5701207a3b4dc7801589c (diff)
PAL: Improvements in tables and formatting
+ legend + footnote + output to log + fix formatting in the methodology section Type: Improvements Change-Id: I605615a602b239265fc6768a65c8d33dd793d4c4 Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/presentation/generator_tables.py')
-rw-r--r--resources/tools/presentation/generator_tables.py69
1 files changed, 42 insertions, 27 deletions
diff --git a/resources/tools/presentation/generator_tables.py b/resources/tools/presentation/generator_tables.py
index c06e492ec8..3afa3830fa 100644
--- a/resources/tools/presentation/generator_tables.py
+++ b/resources/tools/presentation/generator_tables.py
@@ -594,6 +594,7 @@ def _tpc_generate_html_table(header, data, out_file_name, legend=u"",
path = u"_tmp/src/vpp_performance_tests/comparisons/"
else:
path = u"_tmp/src/dpdk_performance_tests/comparisons/"
+ logging.info(f" Writing the HTML file to {path}{file_name}.rst")
with open(f"{path}{file_name}.rst", u"wt") as rst_file:
rst_file.write(
u"\n"
@@ -612,11 +613,22 @@ def _tpc_generate_html_table(header, data, out_file_name, legend=u"",
f'</iframe>\n\n'
)
- # TODO: Use html (rst) list for legend and footnote
if legend:
- rst_file.write(legend[1:].replace(u"\n", u" |br| "))
+ try:
+ itm_lst = legend[1:-2].split(u"\n")
+ rst_file.write(
+ f"{itm_lst[0]}\n\n- " + u'\n- '.join(itm_lst[1:]) + u"\n\n"
+ )
+ except IndexError as err:
+ logging.error(f"Legend cannot be written to html file\n{err}")
if footnote:
- rst_file.write(footnote.replace(u"\n", u" |br| ")[1:])
+ try:
+ itm_lst = footnote[1:].split(u"\n")
+ rst_file.write(
+ f"{itm_lst[0]}\n\n- " + u'\n- '.join(itm_lst[1:]) + u"\n\n"
+ )
+ except IndexError as err:
+ logging.error(f"Footnote cannot be written to html file\n{err}")
def table_soak_vs_ndr(table, input_data):
@@ -777,17 +789,17 @@ def table_soak_vs_ndr(table, input_data):
tbl_lst.sort(key=lambda rel: rel[-1], reverse=True)
# Generate csv tables:
- csv_file = f"{table[u'output-file']}.csv"
- with open(csv_file, u"wt") as file_handler:
+ csv_file_name = f"{table[u'output-file']}.csv"
+ with open(csv_file_name, u"wt") as file_handler:
file_handler.write(header_str)
for test in tbl_lst:
file_handler.write(u";".join([str(item) for item in test]) + u"\n")
convert_csv_to_pretty_txt(
- csv_file, f"{table[u'output-file']}.txt", delimiter=u";"
+ csv_file_name, f"{table[u'output-file']}.txt", delimiter=u";"
)
- with open(f"{table[u'output-file']}.txt", u'a') as txt_file:
- txt_file.write(legend)
+ with open(f"{table[u'output-file']}.txt", u'a') as file_handler:
+ file_handler.write(legend)
# Generate html table:
_tpc_generate_html_table(
@@ -1737,12 +1749,13 @@ def table_comparison(table, input_data):
legend = u"\n" + u"\n".join(legend_lst) + u"\n"
footnote = u""
- for rca in rcas:
- footnote += f"\n{rca[u'title']}:\n"
- footnote += rca[u"data"].get(u"footnote", u"")
+ if rcas:
+ footnote += u"\nRCA:\n"
+ for rca in rcas:
+ footnote += rca[u"data"].get(u"footnote", u"")
- csv_file = f"{table[u'output-file']}-csv.csv"
- with open(csv_file, u"wt", encoding='utf-8') as file_handler:
+ csv_file_name = f"{table[u'output-file']}-csv.csv"
+ with open(csv_file_name, u"wt", encoding='utf-8') as file_handler:
file_handler.write(
u",".join([f'"{itm}"' for itm in header_csv]) + u"\n"
)
@@ -1808,19 +1821,21 @@ def table_comparison(table, input_data):
header.extend([rca[u"title"] for rca in rcas])
# Generate csv tables:
- csv_file = f"{table[u'output-file']}.csv"
- with open(csv_file, u"wt", encoding='utf-8') as file_handler:
+ csv_file_name = f"{table[u'output-file']}.csv"
+ logging.info(f" Writing the file {csv_file_name}")
+ with open(csv_file_name, u"wt", encoding='utf-8') as file_handler:
file_handler.write(u";".join(header) + u"\n")
for test in tbl_final:
file_handler.write(u";".join([str(item) for item in test]) + u"\n")
# Generate txt table:
txt_file_name = f"{table[u'output-file']}.txt"
- convert_csv_to_pretty_txt(csv_file, txt_file_name, delimiter=u";")
+ logging.info(f" Writing the file {txt_file_name}")
+ convert_csv_to_pretty_txt(csv_file_name, txt_file_name, delimiter=u";")
- with open(txt_file_name, u'a', encoding='utf-8') as txt_file:
- txt_file.write(legend)
- txt_file.write(footnote)
+ with open(txt_file_name, u'a', encoding='utf-8') as file_handler:
+ file_handler.write(legend)
+ file_handler.write(footnote)
# Generate html table:
_tpc_generate_html_table(
@@ -1969,9 +1984,9 @@ def table_weekly_comparison(table, in_data):
tbl_lst.extend(tbl_lst_none)
# Generate csv table:
- csv_file = f"{table[u'output-file']}.csv"
- logging.info(f" Writing the file {csv_file}")
- with open(csv_file, u"wt", encoding='utf-8') as file_handler:
+ csv_file_name = f"{table[u'output-file']}.csv"
+ logging.info(f" Writing the file {csv_file_name}")
+ with open(csv_file_name, u"wt", encoding='utf-8') as file_handler:
for hdr in header:
file_handler.write(u",".join(hdr) + u"\n")
for test in tbl_lst:
@@ -1982,18 +1997,18 @@ def table_weekly_comparison(table, in_data):
]
) + u"\n")
- txt_file = f"{table[u'output-file']}.txt"
- logging.info(f" Writing the file {txt_file}")
- convert_csv_to_pretty_txt(csv_file, txt_file, delimiter=u",")
+ txt_file_name = f"{table[u'output-file']}.txt"
+ logging.info(f" Writing the file {txt_file_name}")
+ convert_csv_to_pretty_txt(csv_file_name, txt_file_name, delimiter=u",")
# Reorganize header in txt table
txt_table = list()
- with open(txt_file, u"rt", encoding='utf-8') as file_handler:
+ with open(txt_file_name, u"rt", encoding='utf-8') as file_handler:
for line in file_handler:
txt_table.append(line)
try:
txt_table.insert(5, txt_table.pop(2))
- with open(txt_file, u"wt", encoding='utf-8') as file_handler:
+ with open(txt_file_name, u"wt", encoding='utf-8') as file_handler:
file_handler.writelines(txt_table)
except IndexError:
pass