Make FSMManager.fsm a property

This commit is contained in:
Kristóf Tóth 2018-02-26 15:02:06 +01:00
parent 25fd71a2b8
commit 5776400990

View File

@ -39,9 +39,13 @@ class TFWServer:
class FSMManager: class FSMManager:
def __init__(self, fsm_type): def __init__(self, fsm_type):
self.fsm = fsm_type() self._fsm = fsm_type()
self.trigger_handlers = defaultdict(list) self.trigger_handlers = defaultdict(list)
@property
def fsm(self):
return self._fsm
def trigger(self, trigger, message): def trigger(self, trigger, message):
if all((handler() for handler in self.trigger_handlers[trigger])): if all((handler() for handler in self.trigger_handlers[trigger])):
try: self.fsm.trigger(trigger, message=message) try: self.fsm.trigger(trigger, message=message)