aboutsummaryrefslogtreecommitdiff
path: root/lib/macglob.py
diff options
context:
space:
mode:
authorSkip Montanaro <[email protected]>2021-02-16 20:14:16 -0600
committerSkip Montanaro <[email protected]>2021-02-16 20:14:16 -0600
commitc2587c76f1b416cdbecb979e54941933246bf856 (patch)
treebb61ee9128075ce22af4eafa232f13c2e5a07896 /lib/macglob.py
parentd90761a005b24018ae237bf551515772a1de656f (diff)
downloadpython-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.tar.xz
python-0.9.1-patched-QoL-c2587c76f1b416cdbecb979e54941933246bf856.zip
starting over
Diffstat (limited to 'lib/macglob.py')
-rw-r--r--lib/macglob.py64
1 files changed, 32 insertions, 32 deletions
diff --git a/lib/macglob.py b/lib/macglob.py
index cad2c79..f18c396 100644
--- a/lib/macglob.py
+++ b/lib/macglob.py
@@ -8,39 +8,39 @@ import macpath
import fnmatch
def glob(pathname):
- if not has_magic(pathname): return [pathname]
- dirname, basename = macpath.split(pathname)
- if has_magic(dirname):
- if dirname[-1:] = ':': dirname = dirname[:-1]
- list = glob(dirname)
- else:
- list = [dirname]
- if not has_magic(basename):
- result = []
- for dirname in list:
- if basename or macpath.isdir(dirname):
- name = macpath.cat(dirname, basename)
- if macpath.exists(name):
- result.append(name)
- else:
- result = []
- for dirname in list:
- sublist = glob1(dirname, basename)
- for name in sublist:
- result.append(macpath.cat(dirname, name))
- return result
+ if not has_magic(pathname): return [pathname]
+ dirname, basename = macpath.split(pathname)
+ if has_magic(dirname):
+ if dirname[-1:] = ':': dirname = dirname[:-1]
+ list = glob(dirname)
+ else:
+ list = [dirname]
+ if not has_magic(basename):
+ result = []
+ for dirname in list:
+ if basename or macpath.isdir(dirname):
+ name = macpath.cat(dirname, basename)
+ if macpath.exists(name):
+ result.append(name)
+ else:
+ result = []
+ for dirname in list:
+ sublist = glob1(dirname, basename)
+ for name in sublist:
+ result.append(macpath.cat(dirname, name))
+ return result
def glob1(dirname, pattern):
- if not dirname: dirname = ':'
- try:
- names = mac.listdir(dirname)
- except mac.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 = ':'
+ try:
+ names = mac.listdir(dirname)
+ except mac.error:
+ return []
+ result = []
+ for name in names:
+ if name[0] <> '.' or pattern[0] = '.':
+ if fnmatch.fnmatch(name, pattern): result.append(name)
+ return result
def has_magic(s):
- return '*' in s or '?' in s or '[' in s
+ return '*' in s or '?' in s or '[' in s