]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added missing walk() function
authorJack Jansen <jack.jansen@cwi.nl>
Mon, 7 Aug 1995 14:09:27 +0000 (14:09 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Mon, 7 Aug 1995 14:09:27 +0000 (14:09 +0000)
Lib/macpath.py

index 2eddf5aeeec65fd6c1f092a1b00eeaeba424a3e4..32bf14752cdcbc06dc889af620613fb867c62cb6 100644 (file)
@@ -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)