875
875
to exclude some directories, they are then not descended into.
877
877
The data yielded is of the form:
878
[(relpath, basename, kind, lstat, path_from_top), ...]
878
((directory-relpath, directory-path-from-top),
879
[(relpath, basename, kind, lstat), ...]),
880
- directory-relpath is the relative path of the directory being returned
881
with respect to top. prefix is prepended to this.
882
- directory-path-from-root is the path including top for this directory.
883
It is suitable for use with os functions.
884
- relpath is the relative path within the subtree being walked.
885
- basename is the basename of the path
886
- kind is the kind of the file now. If unknown then the file is not
887
present within the tree - but it may be recorded as versioned. See
889
- lstat is the stat data *if* the file was statted.
890
- planned, not implemented:
891
path_from_tree_root is the path from the root of the tree.
880
893
:param prefix: Prefix the relpaths that are yielded with 'prefix'. This
881
894
allows one to walk a subtree but get paths that are relative to a tree
882
895
rooted higher up.
883
896
:return: an iterator over the dirs.
898
#TODO there is a bit of a smell where the results of the directory-
899
# summary in this, and the path from the root, may not agree
900
# depending on top and prefix - i.e. ./foo and foo as a pair leads to
901
# potentially confusing output. We should make this more robust - but
902
# not at a speed cost. RBC 20060731
887
905
_directory = _directory_kind
899
917
for name in sorted(_listdir(top)):
900
918
abspath = top + '/' + name
901
919
statvalue = lstat(abspath)
902
dirblock.append ((relroot + name, name, file_kind_from_stat_mode(statvalue.st_mode), statvalue, abspath))
920
dirblock.append((relroot + name, name,
921
file_kind_from_stat_mode(statvalue.st_mode),
923
yield (currentdir[0], top), dirblock
904
924
# push the user specified dirs from dirblock
905
925
for dir in reversed(dirblock):
906
926
if dir[2] == _directory: