mirror of https://github.com/ARMmbed/mbed-os.git
Fill out remainder of LazyDict dict compatibility
parent
7513d4f897
commit
bf1a69b9be
|
@ -63,6 +63,12 @@ class LazyDict(dict):
|
|||
def __setitem__(self, key, value):
|
||||
self.eager[key] = value
|
||||
|
||||
def __delitem__(self, key):
|
||||
if key in self.eager:
|
||||
del self.eager[key]
|
||||
else:
|
||||
del self.lazy[key]
|
||||
|
||||
def __contains__(self, key):
|
||||
return key in self.eager or key in self.lazy
|
||||
|
||||
|
@ -72,6 +78,12 @@ class LazyDict(dict):
|
|||
def __len__(self):
|
||||
return len(self.eager) + len(self.lazy)
|
||||
|
||||
def __str__(self):
|
||||
return "Lazy{%s}" % (
|
||||
", ".join("%r: %r" % (k, v) for k, v in
|
||||
chain(self.eager.iteritems(), ((k, "not evaluated")
|
||||
for k in self.lazy))))
|
||||
|
||||
def update(self, other):
|
||||
if isinstance(other, LazyDict):
|
||||
self.eager.update(other.eager)
|
||||
|
|
Loading…
Reference in New Issue