MCPcopy
hub / github.com/django/django / update

Method update

django/utils/datastructures.py:200–215  ·  view source on GitHub ↗

Extend rather than replace existing key lists.

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

198 return copy.copy(self)
199
200 def update(self, *args, **kwargs):
201 """Extend rather than replace existing key lists."""
202 if len(args) > 1:
203 raise TypeError("update expected at most 1 argument, got %d" % len(args))
204 if args:
205 arg = args[0]
206 if isinstance(arg, MultiValueDict):
207 for key, value_list in arg.lists():
208 self.setlistdefault(key).extend(value_list)
209 else:
210 if isinstance(arg, Mapping):
211 arg = arg.items()
212 for key, value in arg:
213 self.setlistdefault(key).append(value)
214 for key, value in kwargs.items():
215 self.setlistdefault(key).append(value)
216
217 def dict(self):
218 """Return current object as a dict with singular values."""

Callers 15

test_update_no_argsMethod · 0.95
test_update_dict_argMethod · 0.95
test_update_kwargsMethod · 0.95
encoding.pyFile · 0.45
parse_color_settingFunction · 0.45
_generate_cache_keyFunction · 0.45
html.pyFile · 0.45
__setstate__Method · 0.45

Calls 5

setlistdefaultMethod · 0.95
listsMethod · 0.80
extendMethod · 0.80
itemsMethod · 0.45
appendMethod · 0.45