Warning : this plug-out is not yet available
The Python code reverse is a plug-out directly written in C++.
Note that the Python code reverse cannot be used as a Python code round trip and doesn't allows to update already defined classes having at least one member.
The Python code reverse plug-out may be applied only on a package.
When you start the Python code reverse, it ask for a directory, then it reads all the sources placed under the selected directory and sub-directories. The sources read by the Python code reverse are the ones having the extension specified in the generation settings. The tree formed by the sub-directories produce an equivalent tree of sub-packages, on whose the needed class view and deployment view are made to support the classes and artifacts. When a type is referenced but not defined in the reverse files, a class having the same name is defined under an additional package named unknown.
Obviously the Python code reverse tries to produce the definitions made in BOUML at the artifact / class / operation / relation / attribute levels. When it is possible it creates a relation rather than an attribute. The instance attributes and relation are created from the variable initializations made in the reverse operation __init__. The static attributes and relations are created from the variable initializations made at the toplevel of the class. An operation is declared static when it has the decorator @staticmethod, is it declared abstract when it has the decorator @abstractmethod.
The Python code reverse works in two steps, during the first step it scans all the files to establish the list of defined types, then the second step may reverse the files.
When the Python code reverse has a problem, for instance on a syntax error, it produces a warning in the trace window. The trace window is automatically opened by BOUML, it may also be manually opened through the Tools menu.
The reversed files are considered composed in three parts :
a header without class definition
only classes definition, this part start with the first class and stops before the first form which is not a class. The classes must be at the toplevel level, this means not embedded in a if or other form. This part produces ${definition} in the definition of the artifact
the rest if the file, this part is placed at the end of the definition of the artifact.
Previous : Python generator
Next : Idl generator