Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tosca2doc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CTI Tools
tosca2doc
Commits
a38b63b3
Commit
a38b63b3
authored
6 years ago
by
carignani
Browse files
Options
Downloads
Patches
Plain Diff
added first prototype of document to tosca translator
parent
19350c70
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc2tosca.py
+52
-0
52 additions, 0 deletions
doc2tosca.py
with
52 additions
and
0 deletions
doc2tosca.py
0 → 100644
+
52
−
0
View file @
a38b63b3
#!/bin/python2.7
'''
Generate tosca definitions from Docx specfication
'''
import
sys
import
docx
def
is_tosca_def
(
table
):
'''
Returns true when a table contains TOSCA definitions, i.e.
the table contains just one cell and text starts with an
empty space
'
''
'''
txt
=
table
.
rows
[
0
].
cells
[
0
].
text
[
0
]
return
\
len
(
table
.
rows
)
==
1
and
\
len
(
table
.
columns
)
==
1
and
\
txt
.
startswith
(
'
'
)
try
:
SOL001_FN
=
sys
.
argv
[
1
]
except
:
print
'
Error: Filename missing or filename not a docx document
'
print
'
Usage: doc2tosca <docx-with-tosca-definitions>
'
sys
.
exit
(
1
)
OUT_FN
=
'
try-tosca-export.yaml
'
SOL001
=
docx
.
Document
(
SOL001_FN
)
DEFINITIONS
=
[
t
for
t
in
SOL001
.
tables
if
is_tosca_def
(
t
)]
F
=
open
(
OUT_FN
,
'
w
'
)
HDR
=
'''
tosca_definitions_version: tosca_simple_yaml_1_2
description: ETSI NFV SOL 001 nsd types definitions version 2.5.1
imports:
- etsi_nfv_sol001_vnfd_2_5_1_types.yaml
data_types:
'''
F
.
write
(
HDR
)
for
t
in
DEFINITIONS
:
F
.
write
(
t
.
rows
[
0
].
cells
[
0
].
text
.
encode
(
'
utf-8
'
))
F
.
write
(
'
\n
# -------------------- #
\n
'
)
F
.
write
(
'
\n
'
)
F
.
close
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment