Decorator to register the function as a hook

def hook(name=None, *args, **kwargs):
    """Decorator to register the function as a hook
    """
    def decorator(f):
        if not hasattr(f, "hooks"):
            f.hooks = []
        f.hooks.append((name or f.__name__, args, kwargs))
        return f
    return decorator