##// END OF EJS Templates
Remove uses of iterkeys
Thomas Kluyver -
Show More
@@ -324,7 +324,7 b' def cd_completer(self, event):'
324 324 return [compress_user(relpath, tilde_expand, tilde_val)]
325 325
326 326 # if no completions so far, try bookmarks
327 bks = self.db.get('bookmarks',{}).iterkeys()
327 bks = self.db.get('bookmarks',{})
328 328 bkmatches = [s for s in bks if s.startswith(event.symbol)]
329 329 if bkmatches:
330 330 return bkmatches
@@ -599,7 +599,7 b' class Kernel(Configurable):'
599 599 exec(code, shell.user_global_ns, shell.user_ns)
600 600 result = working.get(resultname)
601 601 finally:
602 for key in ns.iterkeys():
602 for key in ns:
603 603 working.pop(key)
604 604
605 605 result_buf = serialize_object(result,
@@ -91,7 +91,7 b' def serialize_object(obj, buffer_threshold=MAX_BYTES, item_threshold=MAX_ITEMS):'
91 91 buffers.extend(_extract_buffers(c, buffer_threshold))
92 92 elif istype(obj, dict) and len(obj) < item_threshold:
93 93 cobj = {}
94 for k in sorted(obj.iterkeys()):
94 for k in sorted(obj):
95 95 c = can(obj[k])
96 96 buffers.extend(_extract_buffers(c, buffer_threshold))
97 97 cobj[k] = c
@@ -129,7 +129,7 b' def unserialize_object(buffers, g=None):'
129 129 newobj = uncan_sequence(canned, g)
130 130 elif istype(canned, dict) and len(canned) < MAX_ITEMS:
131 131 newobj = {}
132 for k in sorted(canned.iterkeys()):
132 for k in sorted(canned):
133 133 c = canned[k]
134 134 _restore_buffers(c, bufs)
135 135 newobj[k] = uncan(c, g)
@@ -195,21 +195,21 b' class Metadata(dict):'
195 195
196 196 def __getattr__(self, key):
197 197 """getattr aliased to getitem"""
198 if key in self.iterkeys():
198 if key in self:
199 199 return self[key]
200 200 else:
201 201 raise AttributeError(key)
202 202
203 203 def __setattr__(self, key, value):
204 204 """setattr aliased to setitem, with strict"""
205 if key in self.iterkeys():
205 if key in self:
206 206 self[key] = value
207 207 else:
208 208 raise AttributeError(key)
209 209
210 210 def __setitem__(self, key, value):
211 211 """strict static key enforcement"""
212 if key in self.iterkeys():
212 if key in self:
213 213 dict.__setitem__(self, key, value)
214 214 else:
215 215 raise KeyError(key)
@@ -59,7 +59,7 b' class Namespace(dict):'
59 59
60 60 def __getattr__(self, key):
61 61 """getattr aliased to getitem"""
62 if key in self.iterkeys():
62 if key in self:
63 63 return self[key]
64 64 else:
65 65 raise NameError(key)
@@ -43,7 +43,7 b' ISO8601_PAT=re.compile(r"^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d+)Z?([\\+\\-]\\d{'
43 43 def rekey(dikt):
44 44 """Rekey a dict that has been forced to use str keys where there should be
45 45 ints by json."""
46 for k in dikt.iterkeys():
46 for k in dikt:
47 47 if isinstance(k, string_types):
48 48 ik=fk=None
49 49 try:
General Comments 0
You need to be logged in to leave comments. Login now