Class PythonExporter
java.lang.Object
ca.mcscert.jpipe.visitor.AbstractModelExporter
ca.mcscert.jpipe.visitor.PythonExporter
- All Implemented Interfaces:
JustificationVisitor<Void>
Serialises a single
JustificationModel to a Python module: each
element becomes a decorated function named after the element's label
(snake_case via LabelEscaper), carrying:
- one or more
@jpipe_link("<id>"), linking the function back to the originating jPipe element. An element that resulted from a merge is linked by the ids it was merged from rather than by its own, transitively, so a composition of a composition still names the ids as the original source models had them; ids unification minted along the way (unified_0) are left out, having been written in no source file. Every id is then shortened to the least qualified form that still designates the element unambiguously, but never pastcontainer:id, because a bare id would leave a reader of the generated module unable to tell what it refers to; seeAbstractModelExporter.minimalLink(String). @jpipe(produce=[], consume=[])— placeholder decorators to be filled in by the developer.
Each function carries a docstring with the original element label so the full text is always recoverable regardless of escaping.
This visitor operates on one model at a time. Use SelectModel in the
compilation pipeline to extract the desired model from a
before
invoking this exporter.invalid reference
Unit
-
Field Summary
Fields inherited from class AbstractModelExporter
builder, currentModelName -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexport(JustificationModel<?> model) Serialisemodelto Python source text without a file header.export(JustificationModel<?> model, String sourcePath) Serialisemodelto Python source text, optionally prefixed with a generated-file header comment.protected voidexportModel(JustificationModel<?> model) Performs the actual serialisation ofmodel.visit(AbstractSupport abstractSupport) visit(Conclusion conclusion) Emits nothing.visit(SubConclusion subConclusion) Methods inherited from class AbstractModelExporter
initAliases, minimalLink, qualifiedAliasesOf, qualifiedAuthoredOriginalsOf, qualifiedOriginalsOf, qualify, visit, visit, visit
-
Constructor Details
-
PythonExporter
public PythonExporter()
-
-
Method Details
-
export
Serialisemodelto Python source text without a file header.- Parameters:
model- the justification or template to serialise.- Returns:
- Python source text.
-
export
Serialisemodelto Python source text, optionally prefixed with a generated-file header comment.- Parameters:
model- the justification or template to serialise.sourcePath- path of the originating.jdfile, included in the header comment; may benullto omit the header.- Returns:
- Python source text.
-
visit
Emits nothing. The runner never executes a conclusion: it concludes one from whatever supports it, so a function here could never run and there is nothing for a developer to implement. The conclusion remains in the JSON and DOT exports, which describe the model rather than its execution. -
visit
-
visit
-
visit
-
visit
-
exportModel
Description copied from class:AbstractModelExporterPerforms the actual serialisation ofmodel. Implementations must setAbstractModelExporter.currentModelName= model.getName()before calling any element visit methods.- Specified by:
exportModelin classAbstractModelExporter
-