827
828
May also look up by name:
829
830
>>> [x[0] for x in inv.iter_entries()]
831
832
>>> inv = Inventory('TREE_ROOT-12345678-12345678')
832
833
>>> inv.add(InventoryFile('123-123', 'hello.c', ROOT_ID))
833
834
InventoryFile('123-123', 'hello.c', parent_id='TREE_ROOT-12345678-12345678')
880
881
elif isinstance(from_dir, basestring):
881
882
from_dir = self._byid[from_dir]
883
kids = from_dir.children.items()
885
for name, ie in kids:
887
if ie.kind == 'directory':
888
for cn, cie in self.iter_entries(from_dir=ie.file_id):
889
yield pathjoin(name, cn), cie
884
children = from_dir.children.items()
886
children = collections.deque(children)
887
stack = [(u'', children)]
889
from_dir_relpath, children = stack[-1]
892
name, ie = children.popleft()
894
# we know that from_dir_relpath never ends in a slash
895
# and 'f' doesn't begin with one, we can do a string op, rather
896
# than the checks of pathjoin(), though this means that all paths
898
path = from_dir_relpath + '/' + name
902
if ie.kind != 'directory':
905
# But do this child first
906
new_children = ie.children.items()
908
new_children = collections.deque(new_children)
909
stack.append((path, new_children))
910
# Break out of inner loop, so that we start outer loop with child
913
# if we finished all children, pop it off the stack
892
917
def entries(self):
893
918
"""Return list of (path, ie) for all entries except the root.