MCPcopy
hub / github.com/pallets/werkzeug / update

Method update

src/werkzeug/datastructures/headers.py:489–533  ·  view source on GitHub ↗

Replace headers in this object with items from another headers object and keyword arguments. To extend existing keys instead of replacing, use :meth:`extend` instead. If provided, the first argument can be another :class:`Headers` object, a :class:`MultiDict

(
        self,
        arg: (
            Headers
            | MultiDict[str, t.Any]
            | cabc.Mapping[
                str, t.Any | list[t.Any] | tuple[t.Any, ...] | cabc.Set[t.Any]
            ]
            | cabc.Iterable[tuple[str, t.Any]]
            | None
        ) = None,
        /,
        **kwargs: t.Any | list[t.Any] | tuple[t.Any, ...] | cabc.Set[t.Any],
    )

Source from the content-addressed store, hash-verified

487 self._list[key] = [(k, _str_header_value(v)) for k, v in value] # type: ignore[misc]
488
489 def update(
490 self,
491 arg: (
492 Headers
493 | MultiDict[str, t.Any]
494 | cabc.Mapping[
495 str, t.Any | list[t.Any] | tuple[t.Any, ...] | cabc.Set[t.Any]
496 ]
497 | cabc.Iterable[tuple[str, t.Any]]
498 | None
499 ) = None,
500 /,
501 **kwargs: t.Any | list[t.Any] | tuple[t.Any, ...] | cabc.Set[t.Any],
502 ) -> None:
503 """Replace headers in this object with items from another
504 headers object and keyword arguments.
505
506 To extend existing keys instead of replacing, use :meth:`extend`
507 instead.
508
509 If provided, the first argument can be another :class:`Headers`
510 object, a :class:`MultiDict`, :class:`dict`, or iterable of
511 pairs.
512
513 .. versionadded:: 1.0
514 """
515 if arg is not None:
516 if isinstance(arg, (Headers, MultiDict)):
517 for key in arg.keys():
518 self.setlist(key, arg.getlist(key))
519 elif isinstance(arg, cabc.Mapping):
520 for key, value in arg.items():
521 if isinstance(value, (list, tuple, set)):
522 self.setlist(key, value)
523 else:
524 self.set(key, value)
525 else:
526 for key, value in arg:
527 self.set(key, value)
528
529 for key, value in kwargs.items():
530 if isinstance(value, (list, tuple, set)):
531 self.setlist(key, value)
532 else:
533 self.set(key, value)
534
535 def __or__(
536 self,

Callers 4

__ior__Method · 0.95
get_pin_and_cookie_nameFunction · 0.45
__or__Method · 0.45
as_setMethod · 0.45

Calls 5

setlistMethod · 0.95
setMethod · 0.95
keysMethod · 0.45
getlistMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected