MCPcopy
hub / github.com/tornadoweb/tornado / replace

Method replace

tornado/util.py:382–403  ·  view source on GitHub ↗

Replace the named argument in ``args, kwargs`` with ``new_value``. Returns ``(old_value, args, kwargs)``. The returned ``args`` and ``kwargs`` objects may not be the same as the input objects, or the input objects may be mutated. If the named argument was not found

(
        self, new_value: Any, args: Sequence[Any], kwargs: Dict[str, Any]
    )

Source from the content-addressed store, hash-verified

380 return kwargs.get(self.name, default)
381
382 def replace(
383 self, new_value: Any, args: Sequence[Any], kwargs: Dict[str, Any]
384 ) -> Tuple[Any, Sequence[Any], Dict[str, Any]]:
385 """Replace the named argument in ``args, kwargs`` with ``new_value``.
386
387 Returns ``(old_value, args, kwargs)``. The returned ``args`` and
388 ``kwargs`` objects may not be the same as the input objects, or
389 the input objects may be mutated.
390
391 If the named argument was not found, ``new_value`` will be added
392 to ``kwargs`` and None will be returned as ``old_value``.
393 """
394 if self.arg_pos is not None and len(args) > self.arg_pos:
395 # The arg to replace is passed positionally
396 old_value = args[self.arg_pos]
397 args = list(args) # *args is normally a tuple
398 args[self.arg_pos] = new_value
399 else:
400 # The arg to replace is either omitted or passed by keyword.
401 old_value = kwargs.get(self.name)
402 kwargs[self.name] = new_value
403 return old_value, args, kwargs
404
405
406def timedelta_to_seconds(td):

Callers 15

formatMethod · 0.80
get_closestMethod · 0.80
format_dateMethod · 0.80
_normalize_nameMethod · 0.80
environMethod · 0.80
log_messageMethod · 0.80
should_return_304Method · 0.80
parse_url_pathMethod · 0.80
json_encodeFunction · 0.80
url_unescapeFunction · 0.80

Calls 1

getMethod · 0.45

Tested by 15

test_omittedMethod · 0.64
test_positionMethod · 0.64
test_keywordMethod · 0.64
accept_callbackMethod · 0.64
test_non_ssl_requestMethod · 0.64
test_error_loggingMethod · 0.64