MCPcopy Create free account
hub / github.com/ActiveState/code / _walktree_compat

Method _walktree_compat

recipes/Python/259147_FSList/recipe-259147.py:405–433  ·  view source on GitHub ↗

recursively descend the directory tree rooted at top. Return all of the directories as a list. This should work on python2.2

(self, top)

Source from the content-addressed store, hash-verified

403 return pattern
404
405 def _walktree_compat(self, top):
406 '''
407 recursively descend the directory tree rooted at top.
408 Return all of the directories as a list. This should work
409 on python2.2
410 '''
411
412 dirlist = []
413 templist = []
414 try:
415 templist = os.listdir(top)
416 except OSError, err:
417 import errno
418 if err.errno == errno.ENOENT:
419 return []
420
421 for f in templist:
422 pathname = os.path.join(top, f)
423 try:
424 mode = os.stat(pathname)[ST_MODE]
425 except OSError, err:
426 import errno
427 if err.errno == errno.ENOENT:
428 continue
429 if S_ISDIR(mode):
430 # It's a directory, recurse into it
431 dirlist.append(pathname)
432 dirlist.extend(self._walktree_compat(pathname))
433 return dirlist
434
435
436 def __setitem__(self, key, value):

Callers 1

_populateMethod · 0.95

Calls 4

listdirMethod · 0.45
joinMethod · 0.45
appendMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected