# Path: toscaparser/common/exception.py
# class ExceptionCollector(object):
# 
#     exceptions = []
#     collecting = False
# 
#     @staticmethod
#     def clear():
#         del ExceptionCollector.exceptions[:]
# 
#     @staticmethod
#     def start():
#         ExceptionCollector.clear()
#         ExceptionCollector.collecting = True
# 
#     @staticmethod
#     def stop():
#         ExceptionCollector.collecting = False
# 
#     @staticmethod
#     def contains(exception):
#         for ex in ExceptionCollector.exceptions:
#             if str(ex) == str(exception):
#                 return True
#         return False
# 
#     @staticmethod
#     def appendException(exception):
#         if ExceptionCollector.collecting:
#             if not ExceptionCollector.contains(exception):
#                 exception.trace = traceback.extract_stack()[:-1]
#                 ExceptionCollector.exceptions.append(exception)
#         else:
#             raise exception
# 
#     @staticmethod
#     def exceptionsCaught():
#         return len(ExceptionCollector.exceptions) > 0
# 
#     @staticmethod
#     def getTraceString(traceList):
#         traceString = ''
#         for entry in traceList:
#             f, l, m, c = entry[0], entry[1], entry[2], entry[3]
#             traceString += (_('\t\tFile %(file)s, line %(line)s, in '
#                               '%(method)s\n\t\t\t%(call)s\n')
#                             % {'file': f, 'line': l, 'method': m, 'call': c})
#         return traceString
# 
#     @staticmethod
#     def getExceptionReportEntry(exception, full=True):
#         entry = exception.__class__.__name__ + ': ' + str(exception)
#         if full:
#             entry += '\n' + ExceptionCollector.getTraceString(exception.trace)
#         return entry
# 
#     @staticmethod
#     def getExceptions():
#         return ExceptionCollector.exceptions
# 
#     @staticmethod
#     def getExceptionsReport(full=True):
#         report = []
#         for exception in ExceptionCollector.exceptions:
#             report.append(
#                 ExceptionCollector.getExceptionReportEntry(exception, full))
#         return report
# 
#     @staticmethod
#     def assertExceptionMessage(exception, message):
#         err_msg = exception.__name__ + ': ' + message
#         report = ExceptionCollector.getExceptionsReport(False)
#         assert err_msg in report, (_('Could not find "%(msg)s" in "%(rep)s".')
#                                    % {'rep': report.__str__(), 'msg': err_msg})
# 
# Path: toscaparser/common/exception.py
# class ValidationError(TOSCAException):
#     msg_fmt = _('%(message)s')
# 
# Path: toscaparser/extensions/exttools.py
# class ExtTools(object):
#     def __init__(self):
#         self.EXTENSION_INFO = self._load_extensions()
# 
#     def _load_extensions(self):
#         '''Dynamically load all the extensions .'''
#         extensions = collections.OrderedDict()
# 
#         extns = extension.ExtensionManager(namespace='toscaparser.extensions',
#                                            invoke_on_load=True).extensions
# 
#         for e in extns:
#             try:
#                 extinfo = importlib.import_module(e.plugin.__module__)
#                 base_path = os.path.dirname(extinfo.__file__)
#                 version = e.plugin().VERSION
#                 defs_file = base_path + '/' + e.plugin().DEFS_FILE
# 
#                 # Sections is an optional attribute
#                 sections = getattr(e.plugin(), 'SECTIONS', ())
# 
#                 extensions[version] = {'sections': sections,
#                                        'defs_file': defs_file}
#             except ImportError:
#                 raise ToscaExtImportError(ext_name=e.name)
#             except AttributeError:
#                 attrs = ', '.join(REQUIRED_ATTRIBUTES)
#                 raise ToscaExtAttributeError(ext_name=e.name, attrs=attrs)
# 
#         return extensions
# 
#     def get_versions(self):
#         return sorted(self.EXTENSION_INFO.keys())
# 
#     def get_sections(self):
#         sections = {}
#         for version in self.EXTENSION_INFO.keys():
#             sections[version] = self.EXTENSION_INFO[version]['sections']
# 
#         return sections
# 
#     def get_defs_file(self, version):
#         versiondata = self.EXTENSION_INFO.get(version)
# 
#         if versiondata:
#             return versiondata.get('defs_file')
#         else:
#             return None


import copy
import logging
import os
import toscaparser.utils.yamlparser
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import ValidationError
from toscaparser.extensions.exttools import ExtTools
        if defs and ndtype in defs:
            # copy the value to avoid that next operations add items in the
            # item definitions
            value = copy.copy(defs[ndtype])
        if parent:
            p = self
            if p:
                while p:
                    if p.defs and ndtype in p.defs:
                        # get the parent value
                        parent_value = p.defs[ndtype]
                        if value:
                            if isinstance(value, dict):
                                for k, v in parent_value.items():
                                    if k not in value.keys():
                                        value[k] = v
                            if isinstance(value, list):
                                for p_value in parent_value:
                                    if p_value not in value:
                                        value.append(p_value)
                        else:
                            value = copy.copy(parent_value)
                    p = p.parent_type
        return value

    def get_definition(self, ndtype):
        value = None
        if not hasattr(self, 'defs'):
            defs = None
            ExceptionCollector.appendException(

# Path: toscaparser/common/exception.py
# class ExceptionCollector(object):
# 
#     exceptions = []
#     collecting = False
# 
#     @staticmethod
#     def clear():
#         del ExceptionCollector.exceptions[:]
# 
#     @staticmethod
#     def start():
#         ExceptionCollector.clear()
#         ExceptionCollector.collecting = True
# 
#     @staticmethod
#     def stop():
#         ExceptionCollector.collecting = False
# 
#     @staticmethod
#     def contains(exception):
#         for ex in ExceptionCollector.exceptions:
#             if str(ex) == str(exception):
#                 return True
#         return False
# 
#     @staticmethod
#     def appendException(exception):
#         if ExceptionCollector.collecting:
#             if not ExceptionCollector.contains(exception):
#                 exception.trace = traceback.extract_stack()[:-1]
#                 ExceptionCollector.exceptions.append(exception)
#         else:
#             raise exception
# 
#     @staticmethod
#     def exceptionsCaught():
#         return len(ExceptionCollector.exceptions) > 0
# 
#     @staticmethod
#     def getTraceString(traceList):
#         traceString = ''
#         for entry in traceList:
#             f, l, m, c = entry[0], entry[1], entry[2], entry[3]
#             traceString += (_('\t\tFile %(file)s, line %(line)s, in '
#                               '%(method)s\n\t\t\t%(call)s\n')
#                             % {'file': f, 'line': l, 'method': m, 'call': c})
#         return traceString
# 
#     @staticmethod
#     def getExceptionReportEntry(exception, full=True):
#         entry = exception.__class__.__name__ + ': ' + str(exception)
#         if full:
#             entry += '\n' + ExceptionCollector.getTraceString(exception.trace)
#         return entry
# 
#     @staticmethod
#     def getExceptions():
#         return ExceptionCollector.exceptions
# 
#     @staticmethod
#     def getExceptionsReport(full=True):
#         report = []
#         for exception in ExceptionCollector.exceptions:
#             report.append(
#                 ExceptionCollector.getExceptionReportEntry(exception, full))
#         return report
# 
#     @staticmethod
#     def assertExceptionMessage(exception, message):
#         err_msg = exception.__name__ + ': ' + message
#         report = ExceptionCollector.getExceptionsReport(False)
#         assert err_msg in report, (_('Could not find "%(msg)s" in "%(rep)s".')
#                                    % {'rep': report.__str__(), 'msg': err_msg})
# 
# Path: toscaparser/common/exception.py
# class ValidationError(TOSCAException):
#     msg_fmt = _('%(message)s')
# 
# Path: toscaparser/extensions/exttools.py
# class ExtTools(object):
#     def __init__(self):
#         self.EXTENSION_INFO = self._load_extensions()
# 
#     def _load_extensions(self):
#         '''Dynamically load all the extensions .'''
#         extensions = collections.OrderedDict()
# 
#         extns = extension.ExtensionManager(namespace='toscaparser.extensions',
#                                            invoke_on_load=True).extensions
# 
#         for e in extns:
#             try:
#                 extinfo = importlib.import_module(e.plugin.__module__)
#                 base_path = os.path.dirname(extinfo.__file__)
#                 version = e.plugin().VERSION
#                 defs_file = base_path + '/' + e.plugin().DEFS_FILE
# 
#                 # Sections is an optional attribute
#                 sections = getattr(e.plugin(), 'SECTIONS', ())
# 
#                 extensions[version] = {'sections': sections,
#                                        'defs_file': defs_file}
#             except ImportError:
#                 raise ToscaExtImportError(ext_name=e.name)
#             except AttributeError:
#                 attrs = ', '.join(REQUIRED_ATTRIBUTES)
#                 raise ToscaExtAttributeError(ext_name=e.name, attrs=attrs)
# 
#         return extensions
# 
#     def get_versions(self):
#         return sorted(self.EXTENSION_INFO.keys())
# 
#     def get_sections(self):
#         sections = {}
#         for version in self.EXTENSION_INFO.keys():
#             sections[version] = self.EXTENSION_INFO[version]['sections']
# 
#         return sections
# 
#     def get_defs_file(self, version):
#         versiondata = self.EXTENSION_INFO.get(version)
# 
#         if versiondata:
#             return versiondata.get('defs_file')
#         else:
#             return None


# Path: toscaparser/elements/entity_type.py
import copy
import logging
import os
import toscaparser.utils.yamlparser
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import ValidationError
from toscaparser.extensions.exttools import ExtTools

        if defs and ndtype in defs:
            # copy the value to avoid that next operations add items in the
            # item definitions
            value = copy.copy(defs[ndtype])
        if parent:
            p = self
            if p:
                while p:
                    if p.defs and ndtype in p.defs:
                        # get the parent value
                        parent_value = p.defs[ndtype]
                        if value:
                            if isinstance(value, dict):
                                for k, v in parent_value.items():
                                    if k not in value.keys():
                                        value[k] = v
                            if isinstance(value, list):
                                for p_value in parent_value:
                                    if p_value not in value:
                                        value.append(p_value)
                        else:
                            value = copy.copy(parent_value)
                    p = p.parent_type
        return value

    def get_definition(self, ndtype):
        value = None
        if not hasattr(self, 'defs'):
            defs = None
            ExceptionCollector.appendException(

                ValidationError(message="defs is " + str(defs)))