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

Method setlist

src/werkzeug/datastructures/headers.py:415–430  ·  view source on GitHub ↗

Remove any existing values for a header and add new ones. :param key: The header key to set. :param values: An iterable of values to set for the key. .. versionadded:: 1.0

(self, key: str, values: cabc.Iterable[t.Any])

Source from the content-addressed store, hash-verified

413 self._list[idx + 1 :] = [t for t in iter_list if t[0].lower() != ikey]
414
415 def setlist(self, key: str, values: cabc.Iterable[t.Any]) -> None:
416 """Remove any existing values for a header and add new ones.
417
418 :param key: The header key to set.
419 :param values: An iterable of values to set for the key.
420
421 .. versionadded:: 1.0
422 """
423 if values:
424 values_iter = iter(values)
425 self.set(key, next(values_iter))
426
427 for value in values_iter:
428 self.add(key, value)
429 else:
430 self.remove(key)
431
432 def setdefault(self, key: str, default: t.Any) -> str:
433 """Return the first value for the key if it is in the headers,

Callers 6

setlistdefaultMethod · 0.95
updateMethod · 0.95
create_instanceMethod · 0.45
test_basic_interfaceMethod · 0.45
test_setlistMethod · 0.45

Calls 3

setMethod · 0.95
addMethod · 0.95
removeMethod · 0.95

Tested by 4

create_instanceMethod · 0.36
test_basic_interfaceMethod · 0.36
test_setlistMethod · 0.36