diff options
author | Tibor Frank <tifrank@cisco.com> | 2020-04-09 10:46:54 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2020-04-09 14:48:19 +0200 |
commit | bf31370e5e5fa3b597229a631ca1d58788aae794 (patch) | |
tree | 5b9c1cd10f5e54b261d18c168d59511df44424e1 /resources/tools/presentation/pal_utils.py | |
parent | 8fcb84c0495e364daf65745a9b23b0d6f0a1d51e (diff) |
PAL: Integrate new comp tables
Change-Id: Ibadf4fabb69bdd9d2412ed8f33c97ab12303800f
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/presentation/pal_utils.py')
-rw-r--r-- | resources/tools/presentation/pal_utils.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/resources/tools/presentation/pal_utils.py b/resources/tools/presentation/pal_utils.py index f296c6b16c..3efa00af2c 100644 --- a/resources/tools/presentation/pal_utils.py +++ b/resources/tools/presentation/pal_utils.py @@ -309,7 +309,7 @@ def convert_csv_to_pretty_txt(csv_file_name, txt_file_name, delimiter=u","): """ txt_table = None - with open(csv_file_name, u"rt") as csv_file: + with open(csv_file_name, u"rt", encoding='utf-8') as csv_file: csv_content = csv.reader(csv_file, delimiter=delimiter, quotechar=u'"') for row in csv_content: if txt_table is None: @@ -319,6 +319,29 @@ def convert_csv_to_pretty_txt(csv_file_name, txt_file_name, delimiter=u","): txt_table.align = u"r" txt_table.align[u"Test Case"] = u"l" txt_table.align[u"RCA"] = u"l" - if txt_table: - with open(txt_file_name, u"wt") as txt_file: + txt_table.align[u"RCA1"] = u"l" + txt_table.align[u"RCA2"] = u"l" + txt_table.align[u"RCA3"] = u"l" + + if not txt_table: + return + + if txt_file_name.endswith(u".txt"): + with open(txt_file_name, u"wt", encoding='utf-8') as txt_file: txt_file.write(str(txt_table)) + elif txt_file_name.endswith(u".rst"): + with open(txt_file_name, u"wt") as txt_file: + txt_file.write( + u"\n" + u".. |br| raw:: html\n\n <br />\n\n\n" + u".. |prein| raw:: html\n\n <pre>\n\n\n" + u".. |preout| raw:: html\n\n </pre>\n\n" + ) + txt_file.write( + u"\n.. only:: html\n\n" + u" .. csv-table::\n" + u" :header-rows: 1\n" + u" :widths: auto\n" + u" :align: center\n" + f" :file: {csv_file_name.split(u'/')[-1]}\n" + ) |