def walk(self, remotepath):
"""Taken from https://gist.github.com/johnfink8/2190472
A stripped down version of os.walk implemented for sftp which
yields tuples: (path, folders, files)
"""
path = remotepath
files = []
folders = []
for f in self.listdir_attr(remotepath):
if S_ISDIR(f.st_mode):
folders.append(f.filename)
else: # non-dir
files.append(f.filename)
yield path, folders, files
for folder in folders:
new_path = os.path.join(remotepath, folder)
for x in self.walk(new_path):
yield x
评论列表
文章目录