Decorate a handler function. The handler should accept keyword
		parameters for values supplied by the bot, a subset of:
		- client
		- connection (alias for client)
		- event
		- channel
		- nick
		- rest
551309
def decorate(self, func):
		
		self.func = func
		self._set_implied_name()
		self.register()
		return func
454606
def add_handler(self, handler):
        """"""
        if not callable(handler):
            raise TypeError("'%s' is not callable." % handler)

        self.append(handler)
430865
def decorate(func, caller):
    
    evaldict = func.__globals__.copy()
    evaldict['_call_'] = caller
    evaldict['_func_'] = func
    fun = FunctionMaker.create(
        func, "return _call_(_func_, %(shortsignature)s)",
        evaldict, __wrapped__=func)
    if hasattr(func, '__qualname__'):
        fun.__qualname__ = func.__qualname__
    return fun
871637
def call(self, func, *args, **kwargs):
        
        wrapped = self.wrap(func)
        return wrapped(*args, **kwargs)
201697
def call_and_wrap(func, *args, **kw):
    '''
    '''
    try:
        return func(*args, **kw)
    except api.exceptions.APIException as ex:
        click_exception(ex)
    except urllib3exc.SSLError:
        # see monkey patch above re InsecurePlatformWarning
        if _insecure_warning:
            click.echo(click.style(str(_insecure_warning[0]), fg='red'))
        raise
914234
def _functionFabric(func_name, argList, oargList, password):
    """"""

    def functionHandler(self, *args, **kwargs):
        call_args = {}

        for (key, value) in oargList.items():
            call_args[key] = value

        for i, arg in enumerate(argList):
            if i < len(args):
                call_args[arg] = args[i]

        for (key, value) in kwargs.items():
            call_args[key] = value

        return _callFunc(self, func_name, password, call_args)

    functionHandler.__name__ = str(func_name)
    return functionHandler
1112622
def hook(self, name):
        
        def wrapper(func):
            self.hooks.add(name, func)
            return func
        return wrapper
646213
def _wrap_class(request_handler, validator):
    
    METHODS = ['get', 'post', 'put', 'head', 'options', 'delete', 'patch']
    for name in METHODS:
        method = getattr(request_handler, name)
        setattr(request_handler, name, _auth_required(method, validator))

    return request_handler
1347817
def wrap(function, *args, **kwargs):
    ''''''
    try:
        req = function(*args, **kwargs)
        logger.debug('Got %s: %s', req.status_code, req.content)
        if req.status_code == 200:
            return req
        else:
            raise ClientException(req.reason, req.content)
    except ClientException:
        raise
    except Exception as exc:
        raise ClientException(exc)
423221
def on(self, type):
        ''''''
        def decorator(self, func):
            '''decorated functions should be written as class methods
                @on('join')
                def on_join(self, channel):
                    print("Joined channel %s" % channel)
            '''
            self._handlers[type].append(func)
            return func

        return decorator
549951
def decorator(d):
    
    defaults = d.__defaults__
    if defaults and defaults[0] is None:
        # Can be applied as @decorator or @decorator(kwargs) because
        # first argument is None
        def decorate(fn=None, **kwargs):
            if fn is None:
                return _functools.partial(decorate, **kwargs)
            else:
                decorated = d(fn, **kwargs)
                _functools.update_wrapper(decorated, fn)
                return decorated
    else:
        # Can only be applied as @decorator
        def decorate(fn):
            decorated = d(fn)
            _functools.update_wrapper(decorated, fn)
            return decorated
    _functools.update_wrapper(decorate, d)
    return decorate
1118763
def decorator_handle(tokens):
    """"""
    defs = []
    decorates = []
    for i, tok in enumerate(tokens):
        if "simple" in tok and len(tok) == 1:
            decorates.append("@" + tok[0])
        elif "test" in tok and len(tok) == 1:
            varname = decorator_var + "_" + str(i)
            defs.append(varname + " = " + tok[0])
            decorates.append("@" + varname)
        else:
            raise CoconutInternalException("invalid decorator tokens", tok)
    return "\n".join(defs + decorates) + "\n"
260656
def on_functiondef(self, node):
        """"""
        # ('name', 'args', 'body', 'decorator_list')
        if node.decorator_list:
            raise Warning("decorated procedures not supported!")
        kwargs = []

        if not valid_symbol_name(node.name) or node.name in self.readonly_symbols:
            errmsg = "invalid function name (reserved word?) %s" % node.name
            self.raise_exception(node, exc=NameError, msg=errmsg)

        offset = len(node.args.args) - len(node.args.defaults)
        for idef, defnode in enumerate(node.args.defaults):
            defval = self.run(defnode)
            keyval = self.run(node.args.args[idef+offset])
            kwargs.append((keyval, defval))

        if version_info[0] == 3:
            args = [tnode.arg for tnode in node.args.args[:offset]]
        else:
            args = [tnode.id for tnode in node.args.args[:offset]]

        doc = None
        nb0 = node.body[0]
        if isinstance(nb0, ast.Expr) and isinstance(nb0.value, ast.Str):
            doc = nb0.value.s

        varkws = node.args.kwarg
        vararg = node.args.vararg
        if version_info[0] == 3:
            if isinstance(vararg, ast.arg):
                vararg = vararg.arg
            if isinstance(varkws, ast.arg):
                varkws = varkws.arg

        self.symtable[node.name] = Procedure(node.name, self, doc=doc,
                                             lineno=self.lineno,
                                             body=node.body,
                                             args=args, kwargs=kwargs,
                                             vararg=vararg, varkws=varkws)
        if node.name in self.no_deepcopy:
            self.no_deepcopy.remove(node.name)
197746
def _get_handler(self, namespace, remove_handler=False):
        
        if hasattr(namespace, '_func'):
            _func = namespace._func
            if remove_handler:
                del namespace._func
            return _func
1099066
def _decorate_urlconf(urlpatterns, decorator=require_auth, *args, **kwargs):
    ''''''

    if isinstance(urlpatterns, (list, tuple)):

        for pattern in urlpatterns:
            if getattr(pattern, 'callback', None):
                pattern._callback = decorator(
                    pattern.callback, *args, **kwargs)
            if getattr(pattern, 'url_patterns', []):
                _decorate_urlconf(
                    pattern.url_patterns, decorator, *args, **kwargs)
    else:
        if getattr(urlpatterns, 'callback', None):
            urlpatterns._callback = decorator(
                urlpatterns.callback, *args, **kwargs)
232010
function decorateEvents(comp) {
    const prototype = /** @type {!Function} */(comp.constructor).prototype;

    if (prototype.__events) return;

    let events = {};

    if (prototype.events) {
        events = prototype.events;
    }

    Object.getOwnPropertyNames(prototype)
        .map(propertyName => handlerMethodPattern.exec(propertyName))
        .filter(x => x)
        .forEach(([methodName, eventType, eventTarget]) => {
            events[eventType] = events[eventType] || {};

            /** @suppress {checkTypes} */
            events[eventType][eventTarget] = comp[methodName];
        })

    prototype.__events = events;
}
904464
def authorized_handler(self, f):
        
        @functools.wraps(f)
        def decorated():
            resp = self._handle_authorize_response()
            return f(resp)
        self._authorized_handler = decorated
        return decorated