stageflow.core module

class stageflow.core.Stage

Bases: object

To implement a stage, inherit this class, and override its functions. Should any non-overridden function ever be called, that will raise an exception, since now the expected behavior is undefined.

enter(data)

Override this with setup code for entry of this stage.

data
Data passed from the exit of the previous Stage.
Returns:Returned values will be ignored.
exit(data)

Override this with teardwn code for exit from this stage, and pass on data for the next stage.

data
Data that was passed to Flow.transition.
Returns:Arbitrary data for the next active Stage.
exit_to_substage(substage, data)

Override this with code to prepare for this stage’s interruption by the substage.

substage
Name of the interrupting substage.
data
Data that was passed to Flow.push_substage.
Returns:Returned data will be passed to the substage’s Stage.enter.
reenter_from_substage(substage, data)

Override this with code that resumes the stage (or whatever other action may be required) after the interrupting substage has exited.

substage
Name of the interrupting substage that has ended.
data
Data returned by the the substage’s Stage.exit.
Returns:Returned values will be ignored.
class stageflow.core.Flow(stages=None, substages=None, initial_stage=None, initial_stage_data=None)

Bases: object

get_current_stage()
get_stages()
Returns:The names of all stages.
add_stage(stage_name, stage)
get_current_substage()
transition(stage_name, data=None)

Exit the current stage and enter another. This can only be done if no substage is active.

stage_name
Name of the stage to transition to
data
Arbitrary data that will be passed to the current stage’s Stage.exit
push_substage(substage_name, data=None)
substage_name
The name of the substage to be entered.
data
Arbitrary data that will be passed to the currently active (sub-)stage’s Stage.exit_to_substage.
pop_substage(data=None)
data
Arbitrary data that will be passed to the currently active (sub-)stage’s Stage.exit.