From 6069e204813a591c56dd462947ab7d60c46640ed Mon Sep 17 00:00:00 2001
From: Michele Carignani <michele.carignani@etsi.org>
Date: Mon, 30 Nov 2020 16:25:26 +0100
Subject: [PATCH] remove 'generated' prefix, fix test, fix regex to parse
 example body

---
 src/doc2tosca.py      |  2 +-
 src/example.py        | 14 ++++++--------
 src/test_doc2tosca.py |  6 +++---
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/doc2tosca.py b/src/doc2tosca.py
index afd823c..53572d8 100644
--- a/src/doc2tosca.py
+++ b/src/doc2tosca.py
@@ -14,7 +14,7 @@ from docx.text.paragraph import Paragraph
 
 from example import generate_examples_between
 
-BASE_FILENAME = "generated_etsi_nfv_sol001_{}_{}_types.yaml"
+BASE_FILENAME = "etsi_nfv_sol001_{}_{}_types.yaml"
 TOSCA_VERSION = "tosca_simple_yaml_1_2"
 DEFAULT_TOSCA_VERSION = "tosca_simple_yaml_1_2"
 SPEC_VERSION = "v2.6.1"
diff --git a/src/example.py b/src/example.py
index c2360ba..ab8fde3 100644
--- a/src/example.py
+++ b/src/example.py
@@ -27,17 +27,15 @@ def is_body_of_example(line: str):
     '''
     Returns true if the line is part of the body of an example.
     '''
-    return line.startswith("imports:") or\
-            line.startswith("node_types:") or\
-            line.startswith("topology_template:") or\
-            line.startswith("description:") or\
-            line.startswith("data_types:") or\
-            line.startswith("  ") or\
-            line.startswith(" ") or\
-            line == ""
+    return line == "" or \
+            line.startswith(".") or \
+            line.startswith("#") or \
+            line.startswith(" ") or \
+            bool(re.match(r'^[a-zA-Z_]*:',line))
 
 def get_example_file_name(line: str):
     '''
+    Looks for the YAML filename in the line of text
     '''
     matches = re.search(r'[a-zA-Z0-9_.]*.yaml', line)
     if matches is not None:
diff --git a/src/test_doc2tosca.py b/src/test_doc2tosca.py
index 12cc2b3..6353a3c 100644
--- a/src/test_doc2tosca.py
+++ b/src/test_doc2tosca.py
@@ -397,7 +397,7 @@ MyExampleNS_2.yaml:"""
     line3 = """Virtual IP address connection points (VipCps) are used to allocate one or multiple IP addresses that are shared by other CP instances, which may be instances of the same or of different VduCp or VnfExtCp nodes."""
 
 
-    assert d2t.get_example_file_name(line1) == "MyExampleNS_2.yaml"
-    assert d2t.get_example_file_name(line2) == "MyExampleNs_Type.yaml"
-    assert d2t.get_example_file_name(line3) == ""
+    assert exp.get_example_file_name(line1) == "MyExampleNS_2.yaml"
+    assert exp.get_example_file_name(line2) == "MyExampleNs_Type.yaml"
+    assert exp.get_example_file_name(line3) == ""
 
-- 
GitLab