MCPcopy
hub / github.com/opendevops-cn/opendevops / replace

Method replace

scripts/tornado_source_code/tornado/util.py:409–430  ·  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

407 return kwargs.get(self.name, default)
408
409 def replace(
410 self, new_value: Any, args: Sequence[Any], kwargs: Dict[str, Any]
411 ) -> Tuple[Any, Sequence[Any], Dict[str, Any]]:
412 """Replace the named argument in ``args, kwargs`` with ``new_value``.
413
414 Returns ``(old_value, args, kwargs)``. The returned ``args`` and
415 ``kwargs`` objects may not be the same as the input objects, or
416 the input objects may be mutated.
417
418 If the named argument was not found, ``new_value`` will be added
419 to ``kwargs`` and None will be returned as ``old_value``.
420 """
421 if self.arg_pos is not None and len(args) > self.arg_pos:
422 # The arg to replace is passed positionally
423 old_value = args[self.arg_pos]
424 args = list(args) # *args is normally a tuple
425 args[self.arg_pos] = new_value
426 else:
427 # The arg to replace is either omitted or passed by keyword.
428 old_value = kwargs.get(self.name)
429 kwargs[self.name] = new_value
430 return old_value, args, kwargs
431
432
433def timedelta_to_seconds(td):

Callers 15

formatMethod · 0.80
get_closestMethod · 0.80
_normalize_nameMethod · 0.80
environMethod · 0.80
__init__Method · 0.80
parse_url_pathMethod · 0.80
json_encodeFunction · 0.80
url_unescapeFunction · 0.80
__init__Method · 0.80
generateMethod · 0.80
test_omittedMethod · 0.80
test_positionMethod · 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
test_host_headerMethod · 0.64
test_file_uploadMethod · 0.64