diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-08-07 14:09:27 +0000 |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-08-07 14:09:27 +0000 |
commit | e1fcc59fe6f97cf26fd14f85222293a886e6cbf7 (patch) | |
tree | 514cfdf1eb2996e19b58c0f32ad48217f655c05c /Lib/macpath.py | |
parent | 731e61d8dc9fe638cacb6ca4cd1af79b0188bb54 (diff) | |
download | cpython-e1fcc59fe6f97cf26fd14f85222293a886e6cbf7.tar.gz |
Added missing walk() function
Diffstat (limited to 'Lib/macpath.py')
-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 2eddf5aeee..32bf14752c 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) |