Staging
v0.5.1
https://github.com/python/cpython
Revision 79b5bb488e0d7579c5755cdb78d130a5f2b60330 authored by Jack Jansen on 13 May 1997, 11:28:03 UTC, committed by Jack Jansen on 13 May 1997, 11:28:03 UTC
1 parent 141f9a0
Raw File
Tip revision: 79b5bb488e0d7579c5755cdb78d130a5f2b60330 authored by Jack Jansen on 13 May 1997, 11:28:03 UTC
Export a few more New/Convert routines, on Just's request
Tip revision: 79b5bb4
find.py
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
back to top