diff --git a/src/doc2tosca.py b/src/doc2tosca.py index afd823cbc107925279fecbaab22ed6e046840d47..53572d875fc12a6d6f28669af3915dee7a0a1633 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 c2360ba7d5ac7c9e250eead356a3affae4a5f2b9..ab8fde350217943c1c8f4427a07a457a653d3f04 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 12cc2b36a9e368c18017004aa95e84e00d14e1e5..6353a3c84fb857ffa16dfc769d6f3bfc3c7c0adc 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) == ""