yasmin_editor.model package

Submodules

Module contents

Pure Python data model for the YASMIN editor.

class yasmin_editor.model.Concurrence(name: str, description: str = '', keys: list[Key] = <factory>, outcomes: list[Outcome] = <factory>, parameters: list[Parameter] = <factory>, remappings: dict[str, str] = <factory>, parameter_mappings: dict[str, str] = <factory>, state_type: str | None = None, module: str | None = None, class_name: str | None = None, package_name: str | None = None, file_name: str | None = None, default_outcome: str | None = None, states: dict[str, State] = <factory>, outcome_map: dict[str, dict[str, list[str]]] = <factory>, layout: Layout = <factory>, text_blocks: list[TextBlock] = <factory>)

Bases: State

Represents a YASMIN concurrence container.

add_outcome(outcome) None

Add a final outcome to the concurrence.

add_state(state: State) None

Add a child state to the concurrence.

add_text_block(text_block: TextBlock) None

Add a free-form text block to the container.

class_name: str | None
default_outcome: str | None
description: str
file_name: str | None
get_state(name: str) State | None

Return a child state by name.

property is_container: bool

Return whether this state contains child states.

keys: list[Key]
layout: Layout
module: str | None
name: str
outcome_map: dict[str, dict[str, list[str]]]
outcomes: list[Outcome]
package_name: str | None
parameter_mappings: dict[str, str]
parameters: list[Parameter]
remappings: dict[str, str]
remove_outcome(name: str) None

Remove a final outcome and its outcome-map rule.

remove_outcome_rule(outcome: str, state_name: str, state_outcome: str | None = None) None

Remove one outcome rule entry from the concurrence.

remove_state(name: str) None

Remove a child state and all related outcome rules.

remove_text_block(text_block: TextBlock) None

Remove one free-form text block from the container.

rename_child_state_outcome(state_name: str, old_outcome: str, new_outcome: str) None

Rename one child-state outcome used by the outcome map.

rename_outcome(old_name: str, new_name: str) None

Rename a final outcome and update all related references.

rename_state(old_name: str, new_name: str) None

Rename a child state and update all related outcome rules.

set_outcome_rule(outcome: str, state_name: str, state_outcome: str) None

Set one outcome rule entry for the concurrence.

state_type: str | None
states: dict[str, State]
text_blocks: list[TextBlock]
to_string(indent: int = 0) str

Return a human-readable representation of the concurrence.

class yasmin_editor.model.Key(name: str, key_type: str = 'in', description: str = '', default_type: str = '', default_value: Any | None = None)

Bases: object

Represents a blackboard key definition.

default_type: str
default_value: Any
description: str
property has_default: bool

Return whether a default value is defined for this key.

key_type: str
name: str
class yasmin_editor.model.Layout(state_positions: dict[str, ~yasmin_editor.model.layout.Position] = <factory>, outcome_positions: dict[str, ~yasmin_editor.model.layout.Position] = <factory>, outcome_placements: dict[str, ~yasmin_editor.model.layout.OutcomePlacement] = <factory>)

Bases: object

Stores positions for child states and final outcomes inside a container.

create_outcome_alias(name: str, x: float, y: float) str

Create a new visual alias for an existing logical outcome.

ensure_outcome_placement(outcome_name: str, x: float, y: float, instance_id: str | None = None) str

Create or update one visual placement for a logical outcome.

get_outcome_placement(instance_id: str) OutcomePlacement | None

Return one outcome placement by its instance identifier.

get_outcome_placements(outcome_name: str | None = None) list[OutcomePlacement]

Return all stored outcome placements, optionally filtered by outcome name.

get_outcome_position(name: str) Position | None

Return the primary position of a logical final outcome if present.

get_state_position(name: str) Position | None

Return the position of a child state if present.

materialize_primary_outcome_position(name: str) str | None

Convert one legacy primary position into an explicit alias instance.

This is useful when a layout initially loaded one legacy outcome placement without an instance_id and later needs more than one visual alias for the same logical outcome.

outcome_placements: dict[str, OutcomePlacement]
outcome_positions: dict[str, Position]
remove_outcome_placement(instance_id: str) None

Remove one visual placement of a final outcome.

remove_outcome_position(name: str) None

Remove all stored placements of a logical final outcome.

remove_state_position(name: str) None

Remove the stored position of a child state.

rename_outcome_position(old_name: str, new_name: str) None

Rename the stored placements of a logical final outcome.

rename_state_position(old_name: str, new_name: str) None

Rename the stored position of a child state.

set_outcome_position(name: str, x: float, y: float, instance_id: str | None = None) str

Update one stored final-outcome placement.

Without an instance_id this updates the primary visible alias. Use create_outcome_alias() when a new visual alias should be created.

set_primary_outcome_position(name: str, x: float, y: float) None

Store the primary legacy outcome position without creating an alias.

Legacy XML can describe one final outcome position without an explicit instance_id. The editor still supports that representation for stable roundtrips, so callers that intentionally want a non-alias primary placement should use this method instead of set_outcome_position().

set_state_position(name: str, x: float, y: float) None

Set the position of a child state.

state_positions: dict[str, Position]
class yasmin_editor.model.Outcome(name: str, description: str = '')

Bases: object

Represents an outcome of a state or container.

description: str
name: str
class yasmin_editor.model.Position(x: float = 0.0, y: float = 0.0)

Bases: object

Represents a 2D position in the editor canvas.

x: float
y: float
class yasmin_editor.model.State(name: str, description: str = '', keys: list[~yasmin_editor.model.key.Key] = <factory>, outcomes: list[~yasmin_editor.model.outcome.Outcome] = <factory>, parameters: list[~yasmin_editor.model.parameter.Parameter] = <factory>, remappings: dict[str, str] = <factory>, parameter_mappings: dict[str, str] = <factory>, state_type: str | None = None, module: str | None = None, class_name: str | None = None, package_name: str | None = None, file_name: str | None = None)

Bases: object

Base model for all YASMIN states.

add_key(key: Key) None

Add a blackboard key to the state.

add_outcome(outcome: Outcome) None

Add an outcome to the state.

add_parameter(parameter: Parameter) None

Add a declared parameter to the state.

class_name: str | None
description: str
file_name: str | None
get_outcome(name: str) Outcome | None

Return an outcome by name.

property is_container: bool

Return whether this state contains child states.

property is_leaf: bool

Return whether this state is a leaf state.

keys: list[Key]
module: str | None
name: str
outcomes: list[Outcome]
package_name: str | None
parameter_mappings: dict[str, str]
parameters: list[Parameter]
remappings: dict[str, str]
rename_outcome(old_name: str, new_name: str) None

Rename one outcome of this state.

state_type: str | None
to_string(indent: int = 0) str

Return a human-readable representation of the state.

class yasmin_editor.model.StateMachine(name: str, description: str = '', keys: list[Key] = <factory>, outcomes: list[Outcome] = <factory>, parameters: list[Parameter] = <factory>, remappings: dict[str, str] = <factory>, parameter_mappings: dict[str, str] = <factory>, state_type: str | None = None, module: str | None = None, class_name: str | None = None, package_name: str | None = None, file_name: str | None = None, start_state: str | None = None, states: dict[str, State] = <factory>, transitions: dict[str, list[Transition]] = <factory>, layout: Layout = <factory>, text_blocks: list[TextBlock] = <factory>)

Bases: State

Represents a YASMIN state machine container.

add_outcome(outcome) None

Add a final outcome to the state machine.

add_state(state: State) None

Add a child state to the state machine.

add_text_block(text_block: TextBlock) None

Add a free-form text block to the container.

add_transition(state_name: str, transition: Transition) None

Add a transition for a child state.

class_name: str | None
description: str
file_name: str | None
get_state(name: str) State | None

Return a child state by name.

property is_container: bool

Return whether this state contains child states.

keys: list[Key]
layout: Layout
module: str | None
name: str
outcomes: list[Outcome]
package_name: str | None
parameter_mappings: dict[str, str]
parameters: list[Parameter]
remappings: dict[str, str]
remove_outcome(name: str) None

Remove a final outcome and all related transitions.

remove_state(name: str) None

Remove a child state and all related transitions.

remove_text_block(text_block: TextBlock) None

Remove one free-form text block from the container.

remove_transition(state_name: str, source_outcome: str, target: str) None

Remove a transition for a child state.

rename_child_state_outcome(state_name: str, old_outcome: str, new_outcome: str) None

Rename one outcome referenced by transitions of a child state.

rename_outcome(old_name: str, new_name: str) None

Rename a final outcome and update all related references.

rename_state(old_name: str, new_name: str) None

Rename a child state and update all related references.

rename_transition_owner(old_owner: str, new_owner: str) None

Rename one transition owner entry inside this container.

start_state: str | None
state_type: str | None
states: dict[str, State]
text_blocks: list[TextBlock]
to_string(indent: int = 0) str

Return a human-readable representation of the state machine.

transitions: dict[str, list[Transition]]
class yasmin_editor.model.TextBlock(x: float = 0.0, y: float = 0.0, content: str = '')

Bases: object

Represents a free-form text annotation inside a container.

content: str
x: float
y: float
class yasmin_editor.model.Transition(source_outcome: str, target: str, target_instance_id: str = '')

Bases: object

Represents a transition from one outcome to a target state or final outcome.

source_outcome: str
target: str
target_instance_id: str
class yasmin_editor.model.ValidationMessage(path: str, message: str)

Bases: object

Represents one validation message.

message: str
path: str
class yasmin_editor.model.ValidationResult(errors: list[~yasmin_editor.model.validation.ValidationMessage] = <factory>, warnings: list[~yasmin_editor.model.validation.ValidationMessage] = <factory>)

Bases: object

Collects validation errors and warnings.

add_error(path: str, message: str) None

Add one validation error.

add_warning(path: str, message: str) None

Add one validation warning.

errors: list[ValidationMessage]
extend(other: ValidationResult) None

Merge another validation result into this one.

property is_valid: bool

Return whether the validated model contains no errors.

warnings: list[ValidationMessage]
yasmin_editor.model.validate_model(model: State) ValidationResult

Validate a model tree.