"""Filename globbing utility."""
"""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
.lexists(pathname
):
dirname
, basename
= os
.path
.split(pathname
)
return glob1(os
.curdir
, basename
)
if not has_magic(basename
):
if basename
or os
.path
.isdir(dirname
):
name
= os
.path
.join(dirname
, basename
)
if os
.path
.lexists(name
):
sublist
= glob1(dirname
, basename
)
result
.append(os
.path
.join(dirname
, name
))
def glob1(dirname
, pattern
):
if not dirname
: dirname
= os
.curdir
names
= os
.listdir(dirname
)
names
=filter(lambda x
: x
[0]!='.',names
)
return fnmatch
.filter(names
,pattern
)
magic_check
= re
.compile('[*?[]')
return magic_check
.search(s
) is not None