Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CTI Tools
tosca2doc
Commits
454164fa
Commit
454164fa
authored
Nov 30, 2020
by
carignani
Browse files
support tables for examples in Annex A
parent
afdf7ea4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/example.py
View file @
454164fa
...
...
@@ -6,6 +6,7 @@ import re
import
traceback
from
docx.text.paragraph
import
Paragraph
from
docx.table
import
Table
class
Example
():
...
...
@@ -50,6 +51,9 @@ def is_heading(txt :str):
'''
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
):
'''
Parses TOSCA examples. Txt is a list of Docx items (Paragraph, etc.).
...
...
@@ -67,6 +71,9 @@ def parse_all_examples(txt):
if
is_heading
(
linetext
):
clause
=
linetext
.
split
(
"
\t
"
)[
0
]
i
=
1
elif
isinstance
(
line
,
Table
):
if
is_example_table
(
line
):
linetext
=
str
(
line
.
rows
[
0
].
cells
[
0
].
text
)
elif
isinstance
(
line
,
str
):
linetext
=
line
else
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment