pyrser/meta.py
def hook(cls, hookname=None, erase=False):
    """Attach a method to a parsing class and register it as a parser hook.

       The method is registered with its name unless hookname is provided.
    """
    if not hasattr(cls, '_hooks'):
        raise TypeError(
            "%s didn't seems to be a BasicParser subsclasse" % cls.__name__)
    class_hook_list = cls._hooks
    class_rule_list = cls._rules

    def wrapper(f):
        nonlocal hookname
        add_method(cls)(f)
        if hookname is None:
            hookname = f.__name__
        if not erase and (hookname in class_hook_list or hookname in class_rule_list):
            raise TypeError("%s is already define has rule or hook" % hookname)
        if '.' not in hookname:
            hookname = '.'.join([cls.__module__, cls.__name__, hookname])
        set_one(class_hook_list, hookname, f)
        return f
    return wrapper
def hook(cls, hookname=None, erase=False):
    if not hasattr(cls, '_hooks'):
        raise TypeError(
            "%s didn't seems to be a BasicParser subsclasse" % cls.__name__)
    class_hook_list = cls._hooks
    class_rule_list = cls._rules

    def wrapper(f):
        nonlocal hookname
        add_method(cls)(f)
        if hookname is None:
            hookname = f.__name__
        if not erase and (hookname in class_hook_list or hookname in class_rule_list):
            raise TypeError("%s is already define has rule or hook" % hookname)
        if '.' not in hookname:
            hookname = '.'.join([cls.__module__, cls.__name__, hookname])
        set_one(class_hook_list, hookname, f)
        return f
    return wrapper
def hook ( cls , hookname = None , erase = False ) : if not hasattr ( cls , '_hooks' ) : raise TypeError ( "%s didn't seems to be a BasicParser subsclasse" % cls . __name__ ) class_hook_list = cls . _hooks class_rule_list = cls . _rules def wrapper ( f ) : nonlocal hookname add_method ( cls ) ( f ) if hookname is None : hookname = f . __name__ if not erase and ( hookname in class_hook_list or hookname in class_rule_list ) : raise TypeError ( "%s is already define has rule or hook" % hookname ) if '.' not in hookname : hookname = '.' . join ( [ cls . __module__ , cls . __name__ , hookname ] ) set_one ( class_hook_list , hookname , f ) return f return wrapper
Attach a method to a parsing class and register it as a parser hook.

       The method is registered with its name unless hookname is provided.
Attach a method to a parsing class and register it as a parser hook .