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
c29ba673
Commit
c29ba673
authored
Apr 13, 2021
by
carignani
Browse files
metadata as object (not array), empty sections are not outputted, no version number in filename
parent
bd520050
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/doc2tosca.py
View file @
c29ba673
...
@@ -15,7 +15,7 @@ from docx.text.paragraph import Paragraph
...
@@ -15,7 +15,7 @@ from docx.text.paragraph import Paragraph
from
example
import
generate_examples_between
from
example
import
generate_examples_between
BASE_FILENAME
=
"etsi_nfv_sol001_{}_
{}_
types.yaml"
BASE_FILENAME
=
"etsi_nfv_sol001_{}_types.yaml"
TOSCA_VERSION
=
"tosca_simple_yaml_1_3"
TOSCA_VERSION
=
"tosca_simple_yaml_1_3"
DEFAULT_TOSCA_VERSION
=
"tosca_simple_yaml_1_3"
DEFAULT_TOSCA_VERSION
=
"tosca_simple_yaml_1_3"
SPEC_VERSION
=
"v2.6.1"
SPEC_VERSION
=
"v2.6.1"
...
@@ -27,9 +27,9 @@ MODEL_NAMES = ['vnfd', 'nsd', 'pnfd', 'common']
...
@@ -27,9 +27,9 @@ MODEL_NAMES = ['vnfd', 'nsd', 'pnfd', 'common']
HDR
=
'''tosca_definitions_version: {tosca_version}
HDR
=
'''tosca_definitions_version: {tosca_version}
description: ETSI NFV SOL 001 {model} types definitions version {spec_version}
description: ETSI NFV SOL 001 {model} types definitions version {spec_version}
metadata:
metadata:
-
template_name: etsi_nfv_sol001_{model}_types
template_name: etsi_nfv_sol001_{model}_types
-
template_
name
: ETSI_NFV
template_
author
: ETSI_NFV
-
template_version: {spec_version}
template_version: {spec_version}
imports:
imports:
{imports}
{imports}
...
@@ -119,7 +119,7 @@ def tosca_model_info(name, version, imports):
...
@@ -119,7 +119,7 @@ def tosca_model_info(name, version, imports):
'''
'''
return
{
return
{
'name'
:
name
,
'name'
:
name
,
'fn'
:
BASE_FILENAME
.
format
(
version
.
replace
(
"."
,
"-"
),
name
),
'fn'
:
BASE_FILENAME
.
format
(
name
),
'fd'
:
None
,
'fd'
:
None
,
'imports'
:
imports
,
'imports'
:
imports
,
'buf'
:
StringIO
()
'buf'
:
StringIO
()
...
@@ -246,6 +246,7 @@ def gen_tables_btwn(a_id, b_id, content, buf):
...
@@ -246,6 +246,7 @@ def gen_tables_btwn(a_id, b_id, content, buf):
fdesc file. Returns the number of written definitions
fdesc file. Returns the number of written definitions
'''
'''
definitions_count
=
0
definitions_count
=
0
subsection
=
None
for
idx
in
range
(
a_id
,
b_id
):
for
idx
in
range
(
a_id
,
b_id
):
...
@@ -259,10 +260,13 @@ def gen_tables_btwn(a_id, b_id, content, buf):
...
@@ -259,10 +260,13 @@ def gen_tables_btwn(a_id, b_id, content, buf):
if
isinstance
(
tmp_elem
,
Paragraph
)
and
\
if
isinstance
(
tmp_elem
,
Paragraph
)
and
\
is_lvl2_section_hdn
(
tmp_elem
.
text
):
is_lvl2_section_hdn
(
tmp_elem
.
text
):
logging
.
info
(
tmp_elem
.
text
)
logging
.
info
(
tmp_elem
.
text
)
write_subsection_to_file
(
tmp_elem
.
text
.
split
(
"
\t
"
)[
1
],
buf
)
subsection
=
tmp_elem
.
text
.
split
(
"
\t
"
)[
1
]
definitions_count
=
definitions_count
+
1
if
isinstance
(
tmp_elem
,
Table
)
and
is_tosca_def
(
tmp_elem
):
if
isinstance
(
tmp_elem
,
Table
)
and
is_tosca_def
(
tmp_elem
):
if
subsection
is
not
None
:
write_subsection_to_file
(
subsection
,
buf
)
definitions_count
=
definitions_count
+
1
subsection
=
None
write_table_to_file
(
tmp_elem
,
buf
)
write_table_to_file
(
tmp_elem
,
buf
)
definitions_count
=
definitions_count
+
1
definitions_count
=
definitions_count
+
1
...
...
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