study_state_machine package



study_state_machine.context module

Implementation of a finite state machine for studies

class study_state_machine.context.Context(available_states, initial_state=None)

Bases: object

Only if an initial state is passed to the constructor, the context of the current state is set. Otherwise, call transition_to() or load_state() with a name of a State, respectively

add_sample(*args, **kwargs)
property available_states
change_state(*args, **kwargs)
create_study(*args, **kwargs)
property current_state

Load state with given name


state_name – Name of the state


StateNotFoundException – If the state is not found

parse_strategies(strategies, *args, **kwargs)

Parse strategies list and return a state to be transitioned to


Set state as the new current state and set its context


state_name – new current state

study_state_machine.errors module

Collection of state machine related exceptions.

All exceptions inherit from StateMachineException

exception study_state_machine.errors.BehaviorNotAllowedException

Bases: study_state_machine.errors.StateMachineException

Exception if a state does not support a behavior

exception study_state_machine.errors.StateMachineException

Bases: Exception

Generic state machine error

exception study_state_machine.errors.StateNotFoundException

Bases: study_state_machine.errors.StateMachineException

Exception if state is not found by its name

study_state_machine.interfaces module

class study_state_machine.interfaces.IState(context=None)

Bases: abc.ABC

Base class for all states.

The state has a reference to the context in order to change into the next state.

property context
class study_state_machine.interfaces.IStudyState(context=None)

Bases: study_state_machine.interfaces.IState

Base class for all study states

add_sample(*args, **kwargs)
change_state(*args, **kwargs)
create_study(*args, **kwargs)

Module contents