Chisel request decorator
189304
def request(request_callback=None, **kwargs):
    

    if request_callback is None:
        return lambda fn: request(fn, **kwargs)
    else:
        return Request(request_callback, **kwargs).decorate_module(request_callback)
498914
def required(self, fn):
        """"""
        @functools.wraps(fn)
        def decorated(*args, **kwargs):
            if (not self._check_auth()
               # Don't try to force authentication if the request is part
               # of the authentication process - otherwise we end up in a
               # loop.
               and request.blueprint != self.blueprint.name):
                return redirect(url_for("%s.login" % self.blueprint.name,
                                        next=request.url))
            return fn(*args, **kwargs)
        return decorated
1920
def make_request(self, method, *args, **kwargs):
    """"""
    if args and not use_signature:
        raise NotImplementedError("Only keyword arguments allowed in Python2")

    new_kwargs = {kw: unwrap(value) for kw, value in kwargs.items()}

    if use_signature:
        new_args = tuple(unwrap(value) for value in args)
        bound_args = method.signature.bind(
            unwrap(self), *new_args, **new_kwargs).arguments

        # if we encounter any Enum arguments, replace them with their value
        def translate_enum(arg):
            return arg.value if isinstance(arg, Enum) else arg

        for k in bound_args:
            if isinstance(bound_args[k], str):
                continue
            if isinstance(bound_args[k], dict):
                continue

            try:
                x = [translate_enum(arg) for arg in bound_args[k]]
                bound_args[k] = x
            except TypeError:
                bound_args[k] = translate_enum(bound_args[k])

        # replace `self` with the correct keyword
        new_kwargs = {(kw if kw != 'self' else method.field_name): v
                      for kw, v in bound_args.items()}
        # args = tuple(x.value if isinstance(x, Enum) else x for x in args)

    else:
        new_kwargs[self.field_name] = unwrap(self)

    return method.request_type(**new_kwargs)
799603
def optional_argument_decorator(_decorator):
    """"""

    @functools.wraps(_decorator)
    def inner_decorator_make(*args, **kwargs):
        if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
            func = args[0]
            args = tuple()
            kwargs = dict()
        else:
            func = None

        decorator = _decorator(*args, **kwargs)

        if func:
            return decorator(func)
        else:
            return decorator

    return inner_decorator_make
186382
def _request(self):
        
        caller_frame = inspect.getouterframes(inspect.currentframe())[1]
        args, _, _, values = inspect.getargvalues(caller_frame[0])
        caller_name = caller_frame[3]
        kwargs = {arg: values[arg] for arg in args if arg != 'self'}
        func = reduce(
            lambda resource, name: resource.__getattr__(name),
            self.mappings[caller_name].split('.'), self)
        return func(**kwargs)
582567
def make_request_fn():
  """"""
  if FLAGS.cloud_mlengine_model_name:
    request_fn = serving_utils.make_cloud_mlengine_request_fn(
        credentials=GoogleCredentials.get_application_default(),
        model_name=FLAGS.cloud_mlengine_model_name,
        version=FLAGS.cloud_mlengine_model_version)
  else:

    request_fn = serving_utils.make_grpc_request_fn(
        servable_name=FLAGS.servable_name,
        server=FLAGS.server,
        timeout_secs=FLAGS.timeout_secs)
  return request_fn
1233906
function(form, decorator, slots, lookup) {
        return build(form, decorator, function(form, field) {
          if (form.type === 'template') {
            return form.template;
          }
          return $templateCache.get(field.template);
        }, slots, undefined, undefined, lookup);

      }
1186906
def build_request(method, query_params={})
      query   = { token: token }.merge(query_params)
      request = { query: query, method: method, headers: {}, mock: @test_mode }

      if Diffbot.instrumentor
        request.update(
          instrumentor: Diffbot.instrumentor,
          instrumentor_name: "diffbot"
        )
      end

      request
    end
512114
def mock_decorator(*args, **kwargs):
    """"""
    def _called_decorator(dec_func):
        @wraps(dec_func)
        def _decorator(*args, **kwargs):
            return dec_func()
        return _decorator
    return _called_decorator
533658
def request(method='GET'):
    

    def decorator(func):
        @functools.wraps(func)
        def action(self, *args, **kwargs):
            f = furl(self.server)
            path, body = func(self, *args, **kwargs)

            # deal with query string
            query = dict()
            if isinstance(path, tuple):
                path, query = path
            f.path.add(path)
            f.query.set(query)

            status_code, result = send_rest(f.url, method=method.upper(),
                                            body=body,
                                            session=self.session,
                                            headers=self.headers)
            if status_code != httplib.OK:
                self.logger.error("{impl} {url} headers: {headers}, code: {code}".format(
                    impl=method, url=f.url, headers=self.headers, code=status_code))
            return status_code, result

        return action

    return decorator
1000478
def add_inspection(name):
    

    # create the real decorator
    def inspection_inner(func):
        """
        Jishaku inspection decorator
        """

        # pylint: disable=inconsistent-return-statements

        # create an encapsulated version of the inspection that swallows exceptions
        @functools.wraps(func)
        def encapsulated(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except (TypeError, AttributeError, ValueError, OSError):
                return

        INSPECTIONS.append((name, encapsulated))
        return func
    return inspection_inner
826255
def request(self, *args, **kwargs):
        
        return RequestsHandler(*args, api_token=self.api_token,
                               verify=self.mist_client.verify,
                               job_id=self.mist_client.job_id, **kwargs)
689657
def preprocessor(accepts, exports, flag=None):
    """"""
    def decorator(f):
        preprocessors.append((accepts, exports, flag, f))
        return f
    return decorator
1118618
def request_middleware(api=None):
    """"""
    def decorator(middleware_method):
        apply_to_api = hug.API(api) if api else hug.api.from_object(middleware_method)

        class MiddlewareRouter(object):
            __slots__ = ()

            def process_request(self, request, response):
                return middleware_method(request, response)

        apply_to_api.http.add_middleware(MiddlewareRouter())
        return middleware_method
    return decorator
821854
def decorator(cls, func_or_class):
        """"""
        resources = getattr(func_or_class, 'resources', [])
        resources.append(cls)
        func_or_class.resources = resources
        return func_or_class
919202
def decorator(caller, func=None):
    
    if func is None: # returns a decorator
        fun = FunctionMaker(caller)
        first_arg = inspect.getargspec(caller)[0][0]
        src = 'def %s(%s): return _call_(caller, %s)' % (
            caller.__name__, first_arg, first_arg)
        return fun.make(src, dict(caller=caller, _call_=decorator),
                        undecorated=caller)
    else: # returns a decorated function
        fun = FunctionMaker(func)
        src = """def %(name)s(%(signature)s):
    return _call_(_func_, %(signature)s)"""
        return fun.make(src, dict(_func_=func, _call_=caller), undecorated=func)
953580
def user_to_request(handler):
    ''''''
    @wraps(handler)
    async def decorator(*args):
        request = _get_request(args)
        request[cfg.REQUEST_USER_KEY] = await get_cur_user(request)
        return await handler(*args)
    return decorator