How to use the pyecore.utils.DynamicEPackage function in pyecore

To help you get started, we’ve selected a few pyecore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyecore / pyecore / tests / generatedLibrary / test_static_generatelib.py View on Github external
def test_static_init_dynamicEPackage_from_static_epackage():
    dyn = DynamicEPackage(library)
    assert library.Writer.eClass is dyn.Writer
github pyecore / pyecore / tests / xmi / test_xmi_serialization.py View on Github external
def importMetaModel(rset, filename):
        pkg = rset.get_resource( URI( filename ) ).contents[0]
        register( rset, pkg )
        return DynamicEPackage( pkg )
github pyecore / pyecore / tests / test_commands.py View on Github external
B = EClass('B')
    Root.eStructuralFeatures.append(EReference('a_s', A, upper=-1,
                                               containment=True))
    Root.eStructuralFeatures.append(EReference('bs', B, upper=-1,
                                               containment=True))
    A.eStructuralFeatures.append(EAttribute('name', EString))
    simple_tob = EReference('simple_tob', eType=B, containment=True)
    A.eStructuralFeatures.append(simple_tob)
    A.eStructuralFeatures.append(EReference('many_tob', eType=B,
                                            containment=True, upper=-1))
    B.eStructuralFeatures.append(EReference('toa', A))
    B.eStructuralFeatures.append(EReference('inverseA', A,
                                            eOpposite=simple_tob))
    package = EPackage(name='package')
    package.eClassifiers.extend([Root, A, B])
    return DynamicEPackage(package)
github pyecore / pyecore / tests / test_slicing_del.py View on Github external
def simplemm():
    A = EClass('A')
    B = EClass('B')
    A.eStructuralFeatures.append(EAttribute('name', EString))
    A.eStructuralFeatures.append(EAttribute('number', EInt))
    A.eStructuralFeatures.append(EReference('b', B))
    A.eStructuralFeatures.append(EAttribute('names', EString, upper=-1, unique=False))
    A.eStructuralFeatures.append(EAttribute('ints', EInt, upper=-1, unique=False))
    A.eStructuralFeatures.append(EReference('inners', B, upper=-1, unique=False, containment=True))
    A.eStructuralFeatures.append(EReference('cols', B, upper=-1, unique=False))
    A.eStructuralFeatures.append(EAttribute('values', EString, upper=-1))
    pack = EPackage('pack', nsURI='http://pack/1.0', nsPrefix='pack')
    pack.eClassifiers.extend([A, B])
    return DynamicEPackage(pack)
github pyecore / pyecore / tests / test_utils.py View on Github external
def test_dynamic_access_eclasses(simplemm):
    SimpleMM = DynamicEPackage(simplemm)
    assert SimpleMM.A
    assert SimpleMM.B
github pyecore / pyecore / tests / xmi / test_xmi_serialization.py View on Github external
def test_xmi_with_iD_attribute(tmpdir):
    mm_file = os.path.join('tests', 'xmi', 'xmi-tests', 'A.ecore')
    rset = ResourceSet()
    mm = rset.get_resource(mm_file).contents[0]
    rset.metamodel_registry[mm.nsURI] = mm

    mm_dyn = DynamicEPackage(mm)
    root = mm_dyn.Root()
    a = mm_dyn.A()
    b = mm_dyn.B()
    b.nameID = 'uniqueNameForB'
    a.tob = b

    root.a.append(a)
    root.b.append(b)

    localdir = tmpdir.mkdir('pyecore-tmp')
    f1 = localdir.join('model_iD_simple.xmi')
    resource = rset.create_resource(str(f1))
    resource.append(root)
    resource.save()

    root2 = mm_dyn.Root()
github pyecore / pyecore / tests / test_utils.py View on Github external
def test_dynamic_access_innerpackage(complexmm):
    ComplexMM = DynamicEPackage(complexmm)
    assert ComplexMM.A
    assert ComplexMM.B
    assert ComplexMM.inner.C
    assert ComplexMM.inner.D
github pyecore / pyecore / tests / xmi / test_xmi_serialization.py View on Github external
def test_xmi_save_none_value_for_containement(tmpdir):
    rset = ResourceSet()
    ecore_path = os.path.join('tests', 'xmi', 'xmi-tests', 'root.ecore')
    resource = rset.get_resource(ecore_path)
    root = resource.contents[0]
    rset.metamodel_registry[root.nsURI] = root
    mm = DynamicEPackage(root)

    a = mm.A()
    a.b = None

    f =  tmpdir.mkdir('pyecore-tmp').join('none_in_containment.xmi')
    resource = rset.create_resource(URI(str(f)))
    resource.append(a)
    resource.save()

    rset = ResourceSet()
    rset.metamodel_registry[root.nsURI] = root
    resource = rset.get_resource(URI(str(f)))

    assert resource.contents[0] is not None
    assert resource.contents[0].b is None
    assert len(resource.contents[0]._isset) == 0