(self, event, hook)
Properly register a hook.
Properly register a hook.
Properly register a hook .
def register_hook(self, event, hook):
        """Properly register a hook."""

        if event not in self.hooks:
            raise ValueError('Unsupported event specified, with event name "%s"' % (event))

        if isinstance(hook, Callable):
            self.hooks[event].append(hook)
        elif hasattr(hook, '__iter__'):
            self.hooks[event].extend(h for h in hook if isinstance(h, Callable))
def register_hook ( self , event , hook ) : if event not in self . hooks : raise ValueError ( 'Unsupported event specified, with event name "%s"' % ( event ) ) if isinstance ( hook , Callable ) : self . hooks [ event ] . append ( hook ) elif hasattr ( hook , '__iter__' ) : self . hooks [ event ] . extend ( h for h in hook if isinstance ( h , Callable ) )