@@ -332,6 +332,24 @@ def items(self, prefix=""):
332
332
333
333
return res
334
334
335
+ def iteritems (self , prefix = "" ):
336
+ index = self .dct .ROOT
337
+ if not isinstance (prefix , bytes ):
338
+ prefix = prefix .encode ('utf8' )
339
+ if prefix :
340
+ index = self .dct .follow_bytes (prefix , index )
341
+ if not index :
342
+ return
343
+
344
+ completer = wrapper .Completer (self .dct , self .guide )
345
+ completer .start (index , prefix )
346
+
347
+ while completer .next ():
348
+ key , value = completer .key .split (self ._payload_separator )
349
+ # bytes() cast is a python 2.6 fix
350
+ item = (key .decode ('utf8' ), a2b_base64 (bytes (value )))
351
+ yield item
352
+
335
353
def edges (self , prefix = "" ):
336
354
index = self .dct .ROOT
337
355
if not isinstance (prefix , bytes ):
@@ -346,13 +364,15 @@ def edges(self, prefix=""):
346
364
if not edge_follower .start (index , prefix ):
347
365
return res
348
366
349
- res .append (edge_follower .decoded_key )
367
+ vals = self .b_get_value (edge_follower .decoded_key ) or [False ]
368
+ res .extend ([(edge_follower .decoded_key , val ) for val in vals ])
350
369
while edge_follower .next ():
351
- res .append (edge_follower .decoded_key )
370
+ vals = self .b_get_value (edge_follower .decoded_key ) or [False ]
371
+ res .extend ([(edge_follower .decoded_key , val ) for val in vals ])
352
372
353
373
return res
354
374
355
- def iteritems (self , prefix = "" ):
375
+ def iteredges (self , prefix = "" ):
356
376
index = self .dct .ROOT
357
377
if not isinstance (prefix , bytes ):
358
378
prefix = prefix .encode ('utf8' )
@@ -361,14 +381,17 @@ def iteritems(self, prefix=""):
361
381
if not index :
362
382
return
363
383
364
- completer = wrapper .Completer (self .dct , self .guide )
365
- completer .start (index , prefix )
366
-
367
- while completer .next ():
368
- key , value = completer .key .split (self ._payload_separator )
369
- item = (key .decode ('utf8' ), a2b_base64 (bytes (value ))) # bytes() cast is a python 2.6 fix
370
- yield item
384
+ edge_follower = wrapper .EdgeFollower (self .dct , self .guide )
385
+ if not edge_follower .start (index , prefix ):
386
+ return
371
387
388
+ vals = self .b_get_value (edge_follower .decoded_key ) or [False ]
389
+ for val in vals :
390
+ yield (edge_follower .decoded_key , val or False )
391
+ while edge_follower .next ():
392
+ vals = self .b_get_value (edge_follower .decoded_key ) or [False ]
393
+ for val in vals :
394
+ yield (edge_follower .decoded_key , val or False )
372
395
373
396
def _has_value (self , index ):
374
397
return self .dct .follow_bytes (PAYLOAD_SEPARATOR , index )
0 commit comments