Refactor FSMManager.(un)?subscribe() family of methods to accept lists

This commit is contained in:
Kristóf Tóth 2018-02-26 17:52:34 +01:00
parent 5d7223779a
commit 770123310a

View File

@ -60,11 +60,12 @@ class FSMManager:
try: self.fsm.trigger(trigger, message=message)
except AttributeError: log.debug('FSM failed to execute nonexistent trigger: "{}"'.format(trigger))
def subscribe_predicate(self, trigger, predicate):
self.trigger_predicates[trigger].append(predicate)
def subscribe_predicate(self, trigger, *predicates):
self.trigger_predicates[trigger].extend(predicates)
def unsubscribe_predicate(self, trigger, predicate):
self.trigger_predicates[trigger].remove(predicate)
def unsubscribe_predicate(self, trigger, *predicates):
self.trigger_predicates[trigger] = [predicate for predicate in self.trigger_predicates[trigger]
not in predicates]
class FSMUpdater: