Class PythonExporter

java.lang.Object
ca.mcscert.jpipe.visitor.AbstractModelExporter
ca.mcscert.jpipe.visitor.PythonExporter
All Implemented Interfaces:
JustificationVisitor<Void>

public class PythonExporter extends AbstractModelExporter
Serialises a single JustificationModel to a Python module: each element becomes a decorated function named after the element's label (snake_case via LabelEscaper). Two decorators are emitted per function:
  • @jpipe_link("<modelName:elementId>") — links the function back to the originating jPipe element.
  • @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

invalid reference
Unit
before invoking this exporter.
  • Constructor Details

    • PythonExporter

      public PythonExporter()
  • Method Details

    • export

      public String export(JustificationModel<?> model)
      Serialise model to Python source text without a file header.
      Parameters:
      model - the justification or template to serialise.
      Returns:
      Python source text.
    • export

      public String export(JustificationModel<?> model, String sourcePath)
      Serialise model to Python source text, optionally prefixed with a generated-file header comment.
      Parameters:
      model - the justification or template to serialise.
      sourcePath - path of the originating .jd file, included in the header comment; may be null to omit the header.
      Returns:
      Python source text.
    • visit

      public Void visit(Conclusion conclusion)
    • visit

      public Void visit(SubConclusion subConclusion)
    • visit

      public Void visit(Strategy strategy)
    • visit

      public Void visit(Evidence evidence)
    • visit

      public Void visit(AbstractSupport abstractSupport)
    • exportModel

      protected void exportModel(JustificationModel<?> model)
      Description copied from class: AbstractModelExporter
      Performs the actual serialisation of model. Implementations must set AbstractModelExporter.currentModelName= model.getName() before calling any element visit methods.
      Specified by:
      exportModel in class AbstractModelExporter