コード例 #1
0
ファイル: metamodels.py プロジェクト: exescribis/ScribesInfra
 def outMetamodelDependencies(self):
     """
     Return all metamodel dependencies from the current
     metamodel.
     """
     from modelscripts.megamodels import Megamodel
     return Megamodel.metamodelDependencies(source=self)
コード例 #2
0
def test_display_megamodel():

    print('Metamodels:')

    print('  Metamodels by id')
    for (id, mm) in Megamodel._metamodelById.items():
        print('    %s -> %s' % (id, str(mm)))

    print('  Via metamodels()')
    for mm in Megamodel.metamodels():
        print('    %s' % mm.id)

    print('Metamodel dependencies:')
    for mmd in Megamodel.metamodelDependencies():
        print('  %s' % repr(mmd))

    Megamodel.checkMetamodelLevel()
コード例 #3
0
ファイル: models.py プロジェクト: exescribis/ScribesInfra
    def checkDependencies(self, metamodelDependencies=None):
        #type: (List[MetamodelDependency])->None
        """
        Check if this model has not problems with
        dependencies.
        Do nothing if this is not the case. Otherwise
        it is else raise a ValueError.
        This could be because there is no corresponding
        metamodel dependency for a model metamodel.
        This could also due because of too much outgoing
        dependency of the same typel.
        This could be because of missing dependency.
        """

        #-- metamodels dependencies to be check against
        from modelscripts.megamodels import Megamodel
        if metamodelDependencies is None:
            mm_deps=Megamodel.metamodelDependencies(
                source=self.metamodel)
        else:
            mm_deps=metamodelDependencies

        #-- perform check for all metamodels dependencies
        for mm_dep in mm_deps:
            # all model dependencies of type mm_dep
            # starting from here
            m_deps=self.outDependencies(
                metamodelDependency=mm_dep)
            if len(m_deps)==0 and not mm_dep.optional:
                raise ValueError(
                    'Reference to a %s model'
                    ' is model is missing'
                    % mm_dep.targetMetamodel)
            elif len(m_deps)>=0 and not mm_dep.multiple:
                raise ValueError(
                    'Too many %s models associated'
                    ' with this model'
                    % mm_dep.targetMetamodel)
            else:
                pass
コード例 #4
0
ファイル: metamodels.py プロジェクト: exescribis/ScribesInfra
 def incomingDependencies(self):
     from modelscripts.megamodels import Megamodel
     return Megamodel.metamodelDependencies(target=self)