Mercurial > cpython-lru_cache-weakref
view Lib/lib-old/find.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | a81b6db6d33c |
| children | c3a096bfbd6b |
line wrap: on
line source
import fnmatch import os _debug = 0 _prune = ['(*)'] def find(pattern, dir = os.curdir): list = [] names = os.listdir(dir) names.sort() for name in names: if name in (os.curdir, os.pardir): continue fullname = os.path.join(dir, name) if fnmatch.fnmatch(name, pattern): list.append(fullname) if os.path.isdir(fullname) and not os.path.islink(fullname): for p in _prune: if fnmatch.fnmatch(name, p): if _debug: print "skip", `fullname` break else: if _debug: print "descend into", `fullname` list = list + find(pattern, fullname) return list
