diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-08-07 14:09:27 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-08-07 14:09:27 (GMT) |
commit | a68bfe29ecf584d8cc3862b6049a299ba08d637e (patch) | |
tree | f1e2bd784960babb75c1bcba9a89ec62fe48d9e2 /Lib | |
parent | 3d18593e6d0f26ade9672a7e3fcbb3173e61dca2 (diff) | |
download | cpython-a68bfe29ecf584d8cc3862b6049a299ba08d637e.zip cpython-a68bfe29ecf584d8cc3862b6049a299ba08d637e.tar.gz cpython-a68bfe29ecf584d8cc3862b6049a299ba08d637e.tar.bz2 |
Added missing walk() function
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/macpath.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/macpath.py b/Lib/macpath.py index 2eddf5a..32bf147 100644 --- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -131,3 +131,22 @@ def exists(s): def normpath(s): return s + +# Directory tree walk. +# For each directory under top (including top itself), +# func(arg, dirname, filenames) is called, where +# dirname is the name of the directory and filenames is the list +# of files (and subdirectories etc.) in the directory. +# The func may modify the filenames list, to implement a filter, +# or to impose a different order of visiting. + +def walk(top, func, arg): + try: + names = mac.listdir(top) + except mac.error: + return + func(arg, top, names) + for name in names: + name = join(top, name) + if isdir(name): + walk(name, func, arg) |