def remove_action(self, event, action): """Remove the given action from event. """ event = event.strip().lower() if event not in self.EVENTS: raise ValueError('unknown event', event) handlers = self._ev_handler.setdefault(event, []) if handlers and action in handlers: handlers.remove(action) return
def add_action(self, event, action): """Add the callable action to the given event. action needs to accept 2 parameters: 1. param (packet, sender etc., depends on event) 2. a RmcProtocolHandler instance """ event = event.strip().lower() if event not in self.EVENTS: raise ValueError('unknown event', event) handlers = self._ev_handler.setdefault(event, []) handlers.append(action) return