MCPcopy
hub / github.com/Xyntax/POC-T / update

Method update

thirdparty/odict/odict.py:671–701  ·  view source on GitHub ↗

Update from another OrderedDict or sequence of (key, value) pairs >>> d = OrderedDict(((1, 0), (0, 1))) >>> d.update(OrderedDict(((1, 3), (3, 2), (2, 1)))) >>> d OrderedDict([(1, 3), (0, 1), (3, 2), (2, 1)]) >>> d.update({4: 4}) Traceback (mo

(self, from_od)

Source from the content-addressed store, hash-verified

669 return defval
670
671 def update(self, from_od):
672 """
673 Update from another OrderedDict or sequence of (key, value) pairs
674
675 >>> d = OrderedDict(((1, 0), (0, 1)))
676 >>> d.update(OrderedDict(((1, 3), (3, 2), (2, 1))))
677 >>> d
678 OrderedDict([(1, 3), (0, 1), (3, 2), (2, 1)])
679 >>> d.update({4: 4})
680 Traceback (most recent call last):
681 TypeError: undefined order, cannot get items from dict
682 >>> d.update((4, 4))
683 Traceback (most recent call last):
684 TypeError: cannot convert dictionary update sequence element "4" to a 2-item sequence
685 """
686 if isinstance(from_od, OrderedDict):
687 for key, val in from_od.items():
688 self[key] = val
689 elif isinstance(from_od, dict):
690 # we lose compatibility with other ordered dict types this way
691 raise TypeError('undefined order, cannot get items from dict')
692 else:
693 # FIXME: efficiency?
694 # sequence of 2-item sequences, or error
695 for item in from_od:
696 try:
697 key, val = item
698 except TypeError:
699 raise TypeError('cannot convert dictionary update'
700 ' sequence element "%s" to a 2-item sequence' % item)
701 self[key] = val
702
703 def rename(self, old_key, new_key):
704 """

Callers 9

__init__Method · 0.95
setitemsMethod · 0.95
setvaluesMethod · 0.95
randomMD5Function · 0.80
ClientCommandFunction · 0.80
__setitem__Method · 0.80
odict.pyFile · 0.80
__setstate__Method · 0.80
mainFunction · 0.80

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected