Commit 8dccf3e2 authored by carignani's avatar carignani
Browse files

Merge branch 'clause9'

parents c9b781be ba6191a2
......@@ -89,7 +89,7 @@ def find_sect(sect_to_find, start_idx, doc_content):
'''
while start_idx < len(doc_content):
my_elem = doc_content[start_idx]
if isinstance(my_elem, Paragraph) and my_elem.text == sect_to_find:
if isinstance(my_elem, Paragraph) and my_elem.text.strip() == sect_to_find:
break
start_idx = start_idx + 1
......@@ -111,7 +111,7 @@ def write_table_to_file(tab, buf):
txt = tab.rows[0].cells[0].text
# print("# Included in: " + tab.rows[0].cells[0].text.split("\n")[0])
buf.write("\n".join([pad2(x) for x in txt.split("\n")]))
buf.write("\n".join([x for x in txt.split("\n")]))
# buf.write('\n# -------------------- #\n')
if not txt.endswith('\n'):
buf.write('\n')
......@@ -125,6 +125,12 @@ def generate_tables_between(a_id, b_id, content, buf):
definitions_count = 0
for idx in range(a_id, b_id):
if idx >= len(content):
print("A: " + str(a_id))
print("B: " + str(b_id))
print("IDX: " + str(idx))
print("LEN(CONTENT): " + str(len(content)))
return
tmp_elem = content[idx]
if isinstance(tmp_elem, Table) and is_tosca_def(tmp_elem):
write_table_to_file(tmp_elem, buf)
......@@ -202,11 +208,13 @@ def generate_templates(filename, spec_version=SPEC_VERSION, yaml_root_path='uri'
sect_6_id = find_sect("6\tVNFD TOSCA model", p_id, CONTENT)
sect_7_id = find_sect("7\tNSD TOSCA model", sect_6_id + 1, CONTENT)
sect_7_id = find_sect("7\tNSD TOSCA model", sect_6_id, CONTENT)
sect_8_id = find_sect("8\tPNFD TOSCA model", sect_7_id + 1, CONTENT)
sect_8_id = find_sect("8\tPNFD TOSCA model", sect_7_id, CONTENT)
annex_a_id = find_sect("Annex A (informative):", sect_7_id + 1, CONTENT)
sect_9_id = find_sect("9\tCommon Definitions", sect_8_id, CONTENT)
annex_a_id = find_sect("Annex A (informative):", sect_9_id, CONTENT)
count = generate_tables_between(sect_6_id, sect_7_id, CONTENT, MODELS['vnfd']['buf'])
print("Printed " + str(count) + " types to " + "VNFD\n\n\n")
......@@ -214,9 +222,12 @@ def generate_templates(filename, spec_version=SPEC_VERSION, yaml_root_path='uri'
count = generate_tables_between(sect_7_id, sect_8_id, CONTENT, MODELS['nsd']['buf'])
print("Printed " + str(count) + " types to " + "NSD\n\n\n")
count = generate_tables_between(sect_8_id, annex_a_id, CONTENT, MODELS['pnfd']['buf'])
count = generate_tables_between(sect_8_id, sect_9_id, CONTENT, MODELS['pnfd']['buf'])
print("Printed " + str(count) + " types to " + "PNFD\n\n\n")
count = generate_tables_between(sect_9_id, annex_a_id, CONTENT, MODELS['common']['buf'])
print("Printed " + str(count) + " types to " + "Common\n\n\n")
def print_to_files(prefix=None):
'''
......
......@@ -40,6 +40,7 @@
<li><code>6 VNFD TOSCA model</code></li>
<li><code>7 NSD TOSCA model</code></li>
<li><code>8 PNFD TOSCA model</code>,</li>
<li><code>9 Common Definitions</code>,</li>
</ul>
<p>Step 2: For each of the section after the heading (and until the next heading is found), the tool searches for tables with the following properties:</p>
......@@ -49,12 +50,13 @@
<li>the content matches the regular expression <code>^tosca\.[a-zA-Z\.:0-9\s]*$</code>, i.e. the text starts with <code>tosca.</code> and contains letters, numbers, <code>:</code> or white space.</li>
</ul>
<p>Step 3: The three sets of generated definitions are written to files named:</p>
<p>Step 3: The four sets of generated definitions are written to files named:</p>
<ul>
<li><code>generated_etsi_nfv_sol001_vnfd_types.yaml</code></li>
<li><code>generated_etsi_nfv_sol001_nsd_types.yaml</code></li>
<li><code>generated_etsi_nfv_sol001_pnfd_types.yaml</code></li>
<li><code>generated_etsi_nfv_sol001_common_types.yaml</code></li>
</ul>
<p>Step 4: The files are archived in a zip file named <code>tosca_defs.zip</code> which is served as a response.</p>
......
......@@ -5,17 +5,19 @@ Step 1: In the uploaded Document it searches for headings equal to:
* `6\tVNFD TOSCA model`
* `7\tNSD TOSCA model`
* `8\tPNFD TOSCA model`,
* `9\tCommon Definitions`,
Step 2: For each of the section after the heading (and until the next heading is found), the tool searches for tables with the following properties:
* It contains only one cell (i.e. one row and one column) and
* the content matches the regular expression `^tosca\.[a-zA-Z\.:0-9\s]*$`, i.e. the text starts with `tosca.` and contains letters, numbers, `:` or white space.
Step 3: The three sets of generated definitions are written to files named:
Step 3: The four sets of generated definitions are written to files named:
* `generated_etsi_nfv_sol001_vnfd_types.yaml`
* `generated_etsi_nfv_sol001_nsd_types.yaml`
* `generated_etsi_nfv_sol001_pnfd_types.yaml`
* `generated_etsi_nfv_sol001_common_types.yaml`
Step 4: The files are archived in a zip file named `tosca_defs.zip` which is served as a response.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment