X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=tosca2heat%2Ftosca-parser%2Ftoscaparser%2Fimports.py;h=429a39632ffb18bf7199bd7be7bf8ff3c1b175f6;hb=HEAD;hp=86c10f016fef96ac546f9b2b101bfe28271a9b3f;hpb=2323c9da55a018b1b1995abd5d05f4cdf2be31d5;p=parser.git diff --git a/tosca2heat/tosca-parser/toscaparser/imports.py b/tosca2heat/tosca-parser/toscaparser/imports.py index 86c10f0..429a396 100644 --- a/tosca2heat/tosca-parser/toscaparser/imports.py +++ b/tosca2heat/tosca-parser/toscaparser/imports.py @@ -37,7 +37,7 @@ class ImportsLoader(object): tpl=None): self.importslist = importslist self.custom_defs = {} - self.nested_topo_tpls = [] + self.nested_tosca_tpls = [] if not path and not tpl: msg = _('Input tosca template is not provided.') log.warning(msg) @@ -57,8 +57,8 @@ class ImportsLoader(object): def get_custom_defs(self): return self.custom_defs - def get_nested_topo_tpls(self): - return self.nested_topo_tpls + def get_nested_tosca_tpls(self): + return self.nested_tosca_tpls def _validate_and_load_imports(self): imports_names = set() @@ -98,7 +98,7 @@ class ImportsLoader(object): custom_type, import_def) self._update_custom_def(custom_type, None) - self._update_nested_topo_tpls(full_file_name, custom_type) + self._update_nested_tosca_tpls(full_file_name, custom_type) def _update_custom_def(self, custom_type, namespace_prefix): outer_custom_types = {} @@ -106,6 +106,9 @@ class ImportsLoader(object): outer_custom_types = custom_type.get(type_def) if outer_custom_types: if type_def == "imports": + for i in self.custom_defs.get('imports', []): + if i not in outer_custom_types: + outer_custom_types.append(i) self.custom_defs.update({'imports': outer_custom_types}) else: if namespace_prefix: @@ -119,10 +122,10 @@ class ImportsLoader(object): else: self.custom_defs.update(outer_custom_types) - def _update_nested_topo_tpls(self, full_file_name, custom_tpl): + def _update_nested_tosca_tpls(self, full_file_name, custom_tpl): if full_file_name and custom_tpl: topo_tpl = {full_file_name: custom_tpl} - self.nested_topo_tpls.append(topo_tpl) + self.nested_tosca_tpls.append(topo_tpl) def _validate_import_keys(self, import_name, import_uri_def): if self.FILE not in import_uri_def.keys(): @@ -221,7 +224,7 @@ class ImportsLoader(object): dir_path = os.path.dirname(os.path.abspath( self.path)) if file_path[0] != '' and dir_path.endswith( - file_path[0]): + file_path[0]): import_template = dir_path + "/" +\ file_path[2] if not os.path.isfile(import_template):