PyAlaOCL does not provide a OCL interpreter implemented in python. It “just” allows python programmers familiar with OCL to write expressions à la OCL in python programs. For instance instead of writing the following OCL expression:
joe the programmer will write instead this python expression:
>>> Set(-3,2,-1,-2,-5).excluding(2).forAll(lambda x:x<0) True
While the OCL syntax is not retained (python syntax can not be extended), the power of OCL is still there. Almost the full OCL library is supported including features like closure making it possible to write rather complex traversals in a rather concise and elegant way. Some additional operators are also added to take profit of python while keeping the spirit of OCL.
And last, but not least, PyAlaOCL can (optionally) be integrated in different python settings making it even more handy to use:
- jinja2 integration. PyAlaOCL expressions can be written within jinja2 templates, increasing the expression power of jinja2.
- jython integration. Java collections such as Set or List can be instrumented so that PyAlaOCL expressions work on them. This makes it possible to work with Java apis in a seamless way.
- modelio integration. PyAlaOCL can be used in the context of modelio, the open source UML environment, bringing à la OCL support to modelio.
- USE OCL integration. The integration with the USE OCL environment has been moved to its own project. See PyUseOCL documentation.
The code is open source, and available at github.
- Quick Start Guide
- Jinja2 Integration
- Jython Integration
- Modelio Integration