Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a68bfe2

Browse files
committed
Added missing walk() function
1 parent 3d18593 commit a68bfe2

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lib/macpath.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,22 @@ def exists(s):
131131

132132
def normpath(s):
133133
return s
134+
135+
# Directory tree walk.
136+
# For each directory under top (including top itself),
137+
# func(arg, dirname, filenames) is called, where
138+
# dirname is the name of the directory and filenames is the list
139+
# of files (and subdirectories etc.) in the directory.
140+
# The func may modify the filenames list, to implement a filter,
141+
# or to impose a different order of visiting.
142+
143+
def walk(top, func, arg):
144+
try:
145+
names = mac.listdir(top)
146+
except mac.error:
147+
return
148+
func(arg, top, names)
149+
for name in names:
150+
name = join(top, name)
151+
if isdir(name):
152+
walk(name, func, arg)

0 commit comments

Comments
 (0)