Gets a context for a target function.

    :rtype: caliendo.hooks.Context
    :returns: The context for the call. Patches are applied and removed within a context.
962393
def get_context(method):
    
    if Context.exists(method):
        return Context.increment(method)
    else:
        return Context(method)
1133085
public function get_context() {
        if (isset($this->context)) {
            return $this->context;
        }
        $this->context = \context::instance_by_id($this->data['contextid'], IGNORE_MISSING);
        return $this->context;
    }
1196832
def session_context(fn):
    
    @functools.wraps(fn)
    def wrap(*args, **kwargs):
        session = args[0].Session()  # obtain from self
        result = fn(*args, session=session, **kwargs)
        session.close()
        return result
    return wrap
304174
def update(self, context):
        
        #Get a list of all the operations that need to be performed and then
        #execute them.
        self._operations = self._get_operations(context)

        for i in range(len(self._operations)):
            self._operations[i].handle()
            self.update_extent(self._operations[i])

        #Last of all, we update the string content of the cached version of
        #the module to have the latest source code.
        if len(self._operations) > 0:
            context.module.update_refstring(context.refstring)
1260188
def context(self, **context):
        
        output = orb.Context(context=self.__context) if self.__context is not None else orb.Context()
        output.update(context)
        return output
235587
def context_processor(self, func):
        
        func = to_coroutine(func)
        self.providers.append(func)
        return func
555205
def spawn(self, context=None):
        
        if context is None:
            context = self.default_context

        if isinstance(context, collections.Callable):
            context = context()

        if not isinstance(context, collections.Mapping):
            raise PatchboardError('Cannot determine a valid context')

        return Client(self, context, self.api, self.endpoint_classes)
332328
def context_factory(apply_globally=False, api=None):
    """"""
    def decorator(context_factory_):
        if apply_globally:
            hug.defaults.context_factory = context_factory_
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(context_factory_)
            apply_to_api.context_factory = context_factory_
        return context_factory_
    return decorator
1195139
def execute(func: types.FunctionType):
    
    spec = getfullargspec(func)
    default = spec.defaults
    arg_cursor = 0

    def get_item(name):
        nonlocal arg_cursor
        ctx = func.__globals__
        value = ctx.get(name, _undef)
        if value is _undef:
            try:
                value = default[arg_cursor]
                arg_cursor += 1
            except (TypeError, IndexError):
                raise ValueError(f"Current context has no variable `{name}`")
        return value

    return func(*(get_item(arg_name) for arg_name in spec.args))
926826
def call_with_context(func, context, *args):
    
    return make_context_aware(func, len(args))(*args + (context,))
582655
def sg_get_context():
    
    """

    global _context

    # merge current context
    res = tf.sg_opt()
    for c in _context:
        res += c

    return res
1235717
function hook() {
      var comp = hook.proxy.apply(null, arguments);
      for(var i = 0;i < hooks.length;i++) {
        hooks[i].apply(comp, arguments);
      }
      return comp;
    }
556244
def get_context(self):
        
        ctx = {}
        for clause in self.where_clauses or []:
            clause.update_context(ctx)
        return ctx
850155
def get_context(self):
        
        if not self.is_valid():
            raise ValueError("Cannot generate Context when form is invalid.")
        return dict(request=self.request, **self.cleaned_data)
1110231
def get(self, sid):
        
        return FunctionContext(self._version, service_sid=self._solution['service_sid'], sid=sid, )
422293
def delete_context(apply_globally=False, api=None):
    """"""
    def decorator(delete_context_):
        if apply_globally:
            hug.defaults.delete_context = delete_context_
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(delete_context_)
            apply_to_api.delete_context = delete_context_
        return delete_context_
    return decorator
20680
function Context(hook, opts) {
    var prop;
    this.hook = hook;

    //create new object, to avoid affecting input opts in other places
    //For example context.opts.plugin = Object is done, then it affects by reference
    this.opts = {};
    for (prop in opts) {
    if (opts.hasOwnProperty(prop)) {
        this.opts[prop] = opts[prop];
      }
    }
    this.cmdLine =  process.argv.join(' ');
    this.cordova = require('../cordova/cordova');
}