def iglob(self, pathname):
"""
Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la fnmatch.
"""
if not glob.has_magic(pathname):
if self.ssh.lpath_exists(pathname):
yield pathname
return
dirname, basename = posixpath.split(pathname)
if not dirname:
for name in self.glob1(posixpath.curdir, basename):
yield name
return
if glob.has_magic(dirname):
dirs = self.iglob(dirname)
else:
dirs = [dirname]
if glob.has_magic(basename):
glob_in_dir = self.glob1
else:
glob_in_dir = self.glob0
for dirname in dirs:
for name in glob_in_dir(dirname, basename):
yield posixpath.join(dirname, name)
评论列表
文章目录