MCPcopy Index your code
hub / github.com/nodejs/node / call

Method call

deps/v8/third_party/jinja2/runtime.py:261–303  ·  view source on GitHub ↗

Call the callable with the arguments and keyword arguments provided but inject the active context or environment as first argument if the callable has :func:`pass_context` or :func:`pass_environment`.

(
        __self, __obj: t.Callable, *args: t.Any, **kwargs: t.Any  # noqa: B902
    )

Source from the content-addressed store, hash-verified

259
260 @internalcode
261 def call(
262 __self, __obj: t.Callable, *args: t.Any, **kwargs: t.Any # noqa: B902
263 ) -> t.Union[t.Any, "Undefined"]:
264 """Call the callable with the arguments and keyword arguments
265 provided but inject the active context or environment as first
266 argument if the callable has :func:`pass_context` or
267 :func:`pass_environment`.
268 """
269 if __debug__:
270 __traceback_hide__ = True # noqa
271
272 # Allow callable classes to take a context
273 if (
274 hasattr(__obj, "__call__") # noqa: B004
275 and _PassArg.from_obj(__obj.__call__) is not None # type: ignore
276 ):
277 __obj = __obj.__call__ # type: ignore
278
279 pass_arg = _PassArg.from_obj(__obj)
280
281 if pass_arg is _PassArg.context:
282 # the active context should have access to variables set in
283 # loops and blocks without mutating the context itself
284 if kwargs.get("_loop_vars"):
285 __self = __self.derived(kwargs["_loop_vars"])
286 if kwargs.get("_block_vars"):
287 __self = __self.derived(kwargs["_block_vars"])
288 args = (__self,) + args
289 elif pass_arg is _PassArg.eval_context:
290 args = (__self.eval_ctx,) + args
291 elif pass_arg is _PassArg.environment:
292 args = (__self.environment,) + args
293
294 kwargs.pop("_block_vars", None)
295 kwargs.pop("_loop_vars", None)
296
297 try:
298 return __obj(*args, **kwargs)
299 except StopIteration:
300 return __self.environment.undefined(
301 "value was undefined because a callable raised a"
302 " StopIteration exception"
303 )
304
305 def derived(self, locals: t.Optional[t.Dict[str, t.Any]] = None) -> "Context":
306 """Internal helper function to create a derived context. This is

Callers 15

ClientRequestFunction · 0.45
_http_client.jsFile · 0.45
SocketFunction · 0.45
writeAfterFINFunction · 0.45
net.jsFile · 0.45
ServerFunction · 0.45
OutgoingMessageFunction · 0.45
urlFormatFunction · 0.45
ZlibBaseFunction · 0.45
ZlibFunction · 0.45
DeflateFunction · 0.45
InflateFunction · 0.45

Calls 4

from_objMethod · 0.80
popMethod · 0.80
getMethod · 0.65
derivedMethod · 0.45

Tested by 3

testFunction · 0.36
testFunction · 0.36
testFunction · 0.36