*** /home/hooft/p/basis5/Python-2.0/Lib/glob.py Tue Mar 20 10:09:06 2001 --- ./glob.py Tue Mar 20 10:49:25 2001 *************** *** 4,10 **** import fnmatch import re - def glob(pathname): """Return a list of paths matching a pathname pattern. --- 4,9 ---- *************** *** 17,23 **** else: return [] dirname, basename = os.path.split(pathname) ! if has_magic(dirname): list = glob(dirname) else: list = [dirname] --- 16,24 ---- else: return [] dirname, basename = os.path.split(pathname) ! if not dirname: ! return glob1(os.curdir, basename) ! elif has_magic(dirname): list = glob(dirname) else: list = [dirname] *************** *** 42,53 **** names = os.listdir(dirname) except os.error: return [] ! result = [] ! for name in names: ! if name[0] != '.' or pattern[0] == '.': ! if fnmatch.fnmatch(name, pattern): ! result.append(name) ! return result magic_check = re.compile('[*?[]') --- 43,51 ---- names = os.listdir(dirname) except os.error: return [] ! if pattern[0]!='.': ! names=filter(lambda x: x[0]!='.',names) ! return fnmatch.filter(names,pattern) magic_check = re.compile('[*?[]') *** /home/hooft/p/basis5/Python-2.0/Lib/fnmatch.py Mon Oct 16 23:49:51 2000 --- ./fnmatch.py Tue Mar 20 10:46:19 2001 *************** *** 35,40 **** --- 35,60 ---- pat = os.path.normcase(pat) return fnmatchcase(name, pat) + def filter(names, pat): + """Return the subset of the list NAMES that match PAT""" + import os,posixpath + result=[] + pat=os.path.normcase(pat) + if not _cache.has_key(pat): + res = translate(pat) + _cache[pat] = re.compile(res) + match=_cache[pat].match + if os.path is posixpath: + # normcase on posix is NOP. Optimize it away from the loop. + for name in names: + if match(name): + result.append(name) + else: + for name in names: + if match(os.path.normcase(name)): + result.append(name) + return result + def fnmatchcase(name, pat): """Test whether FILENAME matches PATTERN, including case.