mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 14:51:22 +00:00
Improve YamlFSM initialization logic
This commit is contained in:
parent
c7ee97f0c6
commit
7f583d8d1f
@ -11,10 +11,8 @@ from tfw import FSMBase
|
||||
class YamlFSM(FSMBase):
|
||||
def __init__(self, config_file):
|
||||
self.config = self.parse_config(config_file)
|
||||
self.for_config_states_and_transitions_do(self.patch_config_callbacks)
|
||||
self.setup_states()
|
||||
super().__init__() # FSMBase.__init__() requires states
|
||||
self.for_config_states_and_transitions_do(self.subscribe_and_remove_predicates)
|
||||
self.setup_transitions()
|
||||
|
||||
@staticmethod
|
||||
@ -23,9 +21,11 @@ class YamlFSM(FSMBase):
|
||||
return yaml.safe_load(ifile)
|
||||
|
||||
def setup_states(self):
|
||||
self.for_config_states_and_transitions_do(self.patch_config_callbacks)
|
||||
self.states = [State(**state) for state in self.config['states']]
|
||||
|
||||
def setup_transitions(self):
|
||||
self.for_config_states_and_transitions_do(self.subscribe_and_remove_predicates)
|
||||
for transition in self.config['transitions']:
|
||||
self.add_transition(**transition)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user