Skip to content
Snippets Groups Projects
Commit 454164fa authored by carignani's avatar carignani
Browse files

support tables for examples in Annex A

parent afdf7ea4
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ import re ...@@ -6,6 +6,7 @@ import re
import traceback import traceback
from docx.text.paragraph import Paragraph from docx.text.paragraph import Paragraph
from docx.table import Table
class Example(): class Example():
...@@ -50,6 +51,9 @@ def is_heading(txt :str): ...@@ -50,6 +51,9 @@ def is_heading(txt :str):
''' '''
return txt.startswith("A.") return txt.startswith("A.")
def is_example_table(tab):
return len(tab.rows) == 1 and len(tab.rows[0].cells) == 1
def parse_all_examples(txt): def parse_all_examples(txt):
''' '''
Parses TOSCA examples. Txt is a list of Docx items (Paragraph, etc.). Parses TOSCA examples. Txt is a list of Docx items (Paragraph, etc.).
...@@ -67,6 +71,9 @@ def parse_all_examples(txt): ...@@ -67,6 +71,9 @@ def parse_all_examples(txt):
if is_heading(linetext): if is_heading(linetext):
clause = linetext.split("\t")[0] clause = linetext.split("\t")[0]
i = 1 i = 1
elif isinstance(line, Table):
if is_example_table(line):
linetext = str(line.rows[0].cells[0].text)
elif isinstance(line, str): elif isinstance(line, str):
linetext = line linetext = line
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment