1 """Filename globbing utility."""
9 """Return a list of paths matching a pathname pattern.
11 The pattern may contain simple shell-style wildcards a la fnmatch.
14 if not has_magic(pathname
):
15 if os
.path
.exists(pathname
):
19 dirname
, basename
= os
.path
.split(pathname
)
20 if has_magic(dirname
):
24 if not has_magic(basename
):
27 if basename
or os
.path
.isdir(dirname
):
28 name
= os
.path
.join(dirname
, basename
)
29 if os
.path
.exists(name
):
34 sublist
= glob1(dirname
, basename
)
36 result
.append(os
.path
.join(dirname
, name
))
39 def glob1(dirname
, pattern
):
40 if not dirname
: dirname
= os
.curdir
42 names
= os
.listdir(dirname
)
47 if name
[0] != '.' or pattern
[0] == '.':
48 if fnmatch
.fnmatch(name
, pattern
):
53 magic_check
= re
.compile('[*?[]')
56 return magic_check
.search(s
) is not None