def register_hook(self, event, hook):
if event not in self.hooks:<EOL><INDENT>raise ValueError('<STR_LIT>' % (event))<EOL><DEDENT>if isinstance(hook, Callable):<EOL><INDENT>self.hooks[event].append(hook)<EOL><DEDENT>elif hasattr(hook, '<STR_LIT>'):<EOL><INDENT>self.hooks[event].extend(h for h in hook if isinstance(h, Callable))<EOL><DEDENT>
Properly register a hook.