diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-01-14 23:47:14 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-01-14 23:47:14 (GMT) |
commit | 07e99cb77406e1bc84606f49b743e41b0de8a6d5 (patch) | |
tree | b922cda3a970bffa797269fd550f8d8b032afe5b /Lib/glob.py | |
parent | 88869f9787cd4ceb2298e4b13980beb057687824 (diff) | |
download | cpython-07e99cb77406e1bc84606f49b743e41b0de8a6d5.zip cpython-07e99cb77406e1bc84606f49b743e41b0de8a6d5.tar.gz cpython-07e99cb77406e1bc84606f49b743e41b0de8a6d5.tar.bz2 |
Whitespace normalization.
Diffstat (limited to 'Lib/glob.py')
-rw-r--r-- | Lib/glob.py | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/Lib/glob.py b/Lib/glob.py index 599d41b5..2c21455 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -6,51 +6,51 @@ import re def glob(pathname): - """Return a list of paths matching a pathname pattern. - - The pattern may contain simple shell-style wildcards a la fnmatch. - - """ - 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] - if not has_magic(basename): - result = [] - for dirname in list: - if basename or os.path.isdir(dirname): - name = os.path.join(dirname, basename) - if os.path.exists(name): - result.append(name) - else: - result = [] - for dirname in list: - sublist = glob1(dirname, basename) - for name in sublist: - result.append(os.path.join(dirname, name)) - return result + """Return a list of paths matching a pathname pattern. + + The pattern may contain simple shell-style wildcards a la fnmatch. + + """ + 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] + if not has_magic(basename): + result = [] + for dirname in list: + if basename or os.path.isdir(dirname): + name = os.path.join(dirname, basename) + if os.path.exists(name): + result.append(name) + else: + result = [] + for dirname in list: + sublist = glob1(dirname, basename) + for name in sublist: + result.append(os.path.join(dirname, name)) + 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 + 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 + return magic_check.search(s) is not None |