Skip to main content

Model to text framework for PyEcore, including the Ecore to Python generator

Project description

pypi-version master-build coverage license

Overview

pyecoregen is a code generator, producing Python classes from Ecore models. It can be used at the command line as well as a module. In the latter case the passed model is expected to be an instance of the pyecore metamodel.

After using pyecoregen, you have a Python package representing the classes from the Ecore model. The generated classes are instances of the pyecore metaclasses. Please see pyecore for documentation how to work with them.

Installation

pyecoregen comes in form or a regular Python distribution and can be installed from Github or PyPI with a simple:

$ pip install pyecoregen

The library works with any version of Python >= 3.3.

Usage

Code generation can be done programmatically and directly at the command line.

Command line interface

After installation an executable script pyecoregen has been installed. Assuming library.ecore is your Ecore XMI file, and you want to generate the classes in some/folder, you can do:

$ pyecoregen -vv -e library.ecore -o some/folder

The -vv is optional to raise verbosity to log level DEBUG. You should see output like this:

2017-05-26 08:06:54,303 INFO [multigen.generator] Generating code to '/here/some/folder'.
2017-05-26 08:06:54,304 DEBUG [multigen.generator] <pyecore.ecore.EPackage object at 0x000001DCF3C61E80> --> '/here/some/folder/library/__init__.py'
2017-05-26 08:06:54,363 DEBUG [multigen.generator] <pyecore.ecore.EPackage object at 0x000001DCF3C61E80> --> '/here/some/folder/library/library.py'

Programmatic interface

If you need to generate code from an in-memory representation of a pyecore model, you instantiate the EcoreGenerator class and call the generate method. Assuming you have loaded above model and hold it’s root package in library_pkg, you would generate with:

generator = EcoreGenerator()
generator.generate(library_pkg, 'some/folder')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyecoregen-0.3.0.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

pyecoregen-0.3.0-py3-none-any.whl (11.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page