Table of Contents

Module: mof2py ./src/peak/model/mof2py.py

Python code generation from MOF model

This is still a little rough and the code it generates has not yet been tested. In order to do that, we need to have a mechanism for indexing the created model, such that it can be used as a metamodel for peak.storage.xmi.

Open issues:

  • There are a few unsupported features which will cause generated code not to work or not match the semantics of the supplied model:

    • We don't support actual "pure structure" types; specifically we don't generate correct code for the structure fields.

    • Package inheritance is not supported

    • Constants, TypeAliases, Constraints, Operations, Exceptions, Parameters, Associations, AssociationEnds and Tags do not have any code generated for them.

    • If a model name conflicts with Python keywords, built-ins, or a private/system ('_'-prefixed) name, the generated model may fail with no warning from the generator.

  • Docstring formatting is a bit "off"; notably, we're not wrapping paragraphs, and something seems wrong with linespacing, at least in my tests with the CWM metamodel. This may be purely specific to CWM. At least happydoc seems to make some sense out of the docstrings it sees (non-nested classes only, alas).

Imported modules   
from StringIO import StringIO
from __future__ import generators
from os import makedirs
from os.path import dirname, exists
from peak.api import *
from peak.util.IndentedStream import IndentedStream
from peak.util.advice import advice
Functions   
genPkg
main
  genPkg 
genPkg (
        modelDescr,
        modelFile,
        pkgBase,
        srcDir,
        progress=None,
        )

Generate a peak.model package from a MOF XMI file

modelDescr
title of the model, e.g. "UML 1.3"
modelFile
the XMI file to generate from
pkgBase
dotted package prefix, e.g. "peak.metamodels.UML13.model."
srcDir
directory prefix before pkgBase, e.g. "./src"
progress
a function that will be called with data about each MOF package written; useful for progress indicators.

Any missing directories will be created, but __init__.py files will not be created for parent packages of the specified package, so the output will not be a valid package unless you add them yourself. Files in the destination directory may be overwritten, but existing files that don't correspond to the MOF model contents will not be deleted. If you regenerate a changed model, you might want to delete the target directory tree first.

  main 
main ( prefix='' )

Classes   

MOFFileSet

MOFGenerator

MOFOutline

oncePerObject


Table of Contents

This document was automatically generated on Mon Apr 15 01:11:05 2024 by HappyDoc version 2.1