def list_children(self, path):
"""
Yield all direct children of the given root-relative path, as root-
relative paths. If the path refers to a file, there will be no children.
"""
if len(path) > 0 and not path.endswith("/"):
# We need a trailing slash after a real directory name for urljoin
# to work later
path = path + "/"
# Strip leading slashes from the input path, so we always look inside
# our base path.
path = path.lstrip("/")
# Construct the path to actually go to on the FTP server
ftp_path = urlparse.urljoin(self.base_path, path)
Logger.debug("Listing {}".format(ftp_path))
for child in robust_nlst(self.connection, ftp_path):
# For every child, build a root-relative URL
yield urlparse.urljoin(path, child)
评论列表
文章目录