summaryrefslogtreecommitdiffstats
path: root/Lib/glob.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-01-12 23:26:24 (GMT)
committerGuido van Rossum <guido@python.org>1992-01-12 23:26:24 (GMT)
commitbba77af37aeaf2ee4dbbe1c2d517f9b93a54701b (patch)
tree01a62deda0a54f17a794e896916ae7e24f7cbdaf /Lib/glob.py
parent2817875b2e8ad4b2ef6bb180c63e5bab56da8bc1 (diff)
downloadcpython-bba77af37aeaf2ee4dbbe1c2d517f9b93a54701b.zip
cpython-bba77af37aeaf2ee4dbbe1c2d517f9b93a54701b.tar.gz
cpython-bba77af37aeaf2ee4dbbe1c2d517f9b93a54701b.tar.bz2
Use module 'os'
Diffstat (limited to 'Lib/glob.py')
-rw-r--r--Lib/glob.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/Lib/glob.py b/Lib/glob.py
index 4c7e084..354af39 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -1,14 +1,12 @@
# Module 'glob' -- filename globbing.
-import posix
-import path
+import os
import fnmatch
+
def glob(pathname):
if not has_magic(pathname): return [pathname]
- dirname, basename = path.split(pathname)
- if dirname[-1:] == '/' and dirname <> '/':
- dirname = dirname[:-1]
+ dirname, basename = os.path.split(pathname)
if has_magic(dirname):
list = glob(dirname)
else:
@@ -16,25 +14,24 @@ def glob(pathname):
if not has_magic(basename):
result = []
for dirname in list:
- if basename or path.isdir(dirname):
- name = path.join(dirname, basename)
- if path.exists(name):
+ 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(path.join(dirname, name))
+ result.append(os.path.join(dirname, name))
return result
def glob1(dirname, pattern):
- if not dirname: dirname = '.'
+ if not dirname: dirname = os.curdir
try:
- names = posix.listdir(dirname)
- except posix.error:
+ names = os.listdir(dirname)
+ except os.error:
return []
- names.sort()
result = []
for name in names:
if name[0] <> '.' or pattern[0] == '.':