Use State Mate from Python¶
State Mate exposes the same two-stage workflow used by the CLI: load a Sismic statechart, then render it.
from state_mate import load_statechart, render
statechart = load_statechart("examples/order.yaml")
source = render(statechart)
print(source)
Write generated source yourself¶
from pathlib import Path
from state_mate import load_statechart, render
statechart = load_statechart("examples/order.yaml")
Path("build/order_machine.py").write_text(
render(statechart),
encoding="utf-8",
)
Validate an existing Sismic model¶
If another part of your application already produced a sismic.model.Statechart, call the subset validator directly:
from state_mate import validate_supported_subset
validate_supported_subset(statechart)
This avoids reloading or translating the model. State Mate deliberately operates on Sismic's own objects.