File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Module 'glob' -- filename globbing.
22
3- import posix
4- import path
3+ import os
54import fnmatch
65
6+
77def glob (pathname ):
88 if not has_magic (pathname ): return [pathname ]
9- dirname , basename = path .split (pathname )
10- if dirname [- 1 :] == '/' and dirname <> '/' :
11- dirname = dirname [:- 1 ]
9+ dirname , basename = os .path .split (pathname )
1210 if has_magic (dirname ):
1311 list = glob (dirname )
1412 else :
1513 list = [dirname ]
1614 if not has_magic (basename ):
1715 result = []
1816 for dirname in list :
19- if basename or path .isdir (dirname ):
20- name = path .join (dirname , basename )
21- if path .exists (name ):
17+ if basename or os . path .isdir (dirname ):
18+ name = os . path .join (dirname , basename )
19+ if os . path .exists (name ):
2220 result .append (name )
2321 else :
2422 result = []
2523 for dirname in list :
2624 sublist = glob1 (dirname , basename )
2725 for name in sublist :
28- result .append (path .join (dirname , name ))
26+ result .append (os . path .join (dirname , name ))
2927 return result
3028
3129def glob1 (dirname , pattern ):
32- if not dirname : dirname = '.'
30+ if not dirname : dirname = os . curdir
3331 try :
34- names = posix .listdir (dirname )
35- except posix .error :
32+ names = os .listdir (dirname )
33+ except os .error :
3634 return []
37- names .sort ()
3835 result = []
3936 for name in names :
4037 if name [0 ] <> '.' or pattern [0 ] == '.' :
You can’t perform that action at this time.
0 commit comments