#!/usr/bin/env python
import coral
from coral.addins.constraint.evaluate import PythonConstraintEvaluator

target = None
prj = coral.loadDocument("testPythonConstraint.xml")
assert prj

for elem in prj.contents():
    if elem.oclIsKindOf(coral.lang.UML14.Model):
        target = elem
        assert target

for elem in prj.contents():
    for part in elem.__getAllParts__().select(lambda p:p.oclIsKindOf(coral.lang.CONSTRAINT10.PythonConstraint)):
        pc = PythonConstraintEvaluator(part)
        assert pc
        pc.searchApply(target)

