From 7f583d8d1f6efa86cafa832bc06ddfa3ad3313c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 6 Jul 2018 12:27:26 +0100 Subject: [PATCH] Improve YamlFSM initialization logic --- lib/tfw/yaml_fsm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tfw/yaml_fsm.py b/lib/tfw/yaml_fsm.py index 1c2e1ec..65d8719 100644 --- a/lib/tfw/yaml_fsm.py +++ b/lib/tfw/yaml_fsm.py @@ -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)