| 191 |
| 192 |
| 193 |
| 194 |
| 195 |
| 196 |
| 197 |
| 198 |
| 199 |
| 200 |
| 201 |
| 202 |
| 203 |
| 204 |
| 205 |
| 206 |
| 207 |
| 208 |
| 209 |
| 210 |
| 211 |
| 212 |
| 213 |
| 214 |
| 215 |
| 216 |
| 217 |
| 218 |
| 219 |
| 220 |
| 221 |
| 222 | |
def visit(self, fil=None, rec=None, ignore=_dummyclass): |
""" yields all paths below the current one |
|
fil is a filter (glob pattern or callable), if not matching the |
path will not be yielded, defaulting to None (everything is |
returned) |
|
rec is a filter (glob pattern or callable) that controls whether |
a node is descended, defaulting to None |
|
ignore is an Exception class that is ignoredwhen calling dirlist() |
on any of the paths (by default, all exceptions are reported) |
""" |
if isinstance(fil, str): |
fil = fnmatch(fil) |
if rec: |
if isinstance(rec, str): |
rec = fnmatch(fil) |
elif not callable(rec): |
rec = lambda x: True |
reclist = [self] |
while reclist: |
current = reclist.pop(0) |
try: |
-> dirlist = current.listdir() |
except ignore: |
return |
for p in dirlist: |
if fil is None or fil(p): |
yield p |
if p.check(dir=1) and (rec is None or rec(p)): |
reclist.append(p) | |