home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 1.5)
-
- '''Filename globbing utility.'''
- import os
- import fnmatch
- import re
-
- def glob(pathname):
- '''Return a list of paths matching a pathname pattern.
-
- \tThe pattern may contain simple shell-style wildcards a la fnmatch.
-
- \t'''
- if not has_magic(pathname):
- if os.path.exists(pathname):
- return [
- pathname]
- else:
- return []
-
- (dirname, basename) = os.path.split(pathname)
- if has_magic(dirname):
- list = glob(dirname)
- else:
- list = [
- dirname]
- return result
-
-
- def glob1(dirname, pattern):
- if not dirname:
- dirname = os.curdir
-
-
- try:
- 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('[*?[]')
-
- def has_magic(s):
- return magic_check.search(s) is not None
-
-