906
906
# if we finished all children, pop it off the stack
909
def iter_entries_by_dir(self, from_dir=None):
910
"""Iterate over the entries in a directory first order.
912
This returns all entries for a directory before returning
913
the entries for children of a directory. This is not
914
lexicographically sorted order, and is a hybrid between
915
depth-first and breadth-first.
917
:return: This yields (path, entry) pairs
922
elif isinstance(from_dir, basestring):
923
from_dir = self._byid[from_dir]
925
stack = [(u'', from_dir)]
927
cur_relpath, cur_dir = stack.pop()
930
for child_name, child_ie in sorted(cur_dir.children.iteritems()):
932
child_relpath = cur_relpath + child_name
934
yield child_relpath, child_ie
936
if child_ie.kind == 'directory':
937
child_dirs.append((child_relpath+'/', child_ie))
938
stack.extend(reversed(child_dirs))
909
940
def entries(self):
910
941
"""Return list of (path, ie) for all entries except the root.