mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:46:02 -04:00
Rename and comment tree_to_leaves_iterator
This commit is contained in:
parent
1ccd5676e3
commit
d6c75cb7c2
2 changed files with 8 additions and 5 deletions
|
@ -65,16 +65,19 @@ class TreeCache(object):
|
|||
return popped
|
||||
|
||||
def values(self):
|
||||
return list(popped_to_iterator(self.root))
|
||||
return list(iterate_tree_cache_entry(self.root))
|
||||
|
||||
def __len__(self):
|
||||
return self.size
|
||||
|
||||
|
||||
def popped_to_iterator(d):
|
||||
def iterate_tree_cache_entry(d):
|
||||
"""Helper function to iterate over the leaves of a tree, i.e. a dict of that
|
||||
can contain dicts.
|
||||
"""
|
||||
if isinstance(d, dict):
|
||||
for value_d in d.itervalues():
|
||||
for value in popped_to_iterator(value_d):
|
||||
for value in iterate_tree_cache_entry(value_d):
|
||||
yield value
|
||||
else:
|
||||
if isinstance(d, _Entry):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue