feat: [WIP] remote dir download

This commit is contained in:
Vera Sativa
2019-12-05 11:05:47 -03:00
parent 516e3b14bc
commit 9d0cfcafdf
+12 -2
View File
@@ -547,11 +547,20 @@ class RemoteBASE(object):
if to_info.scheme != "local":
raise NotImplementedError
logger.debug("Downloading '{}' to '{}'".format(from_info, to_info))
makedirs(to_info.parent, exist_ok=True, mode=dir_mode)
if self.isdir(from_info):
# need to create dir here
# also pass the individual file name (file and to)
for file_info in self.walk_files(from_info):
self.single_file_download(file_info, to_info, name, no_progress_bar, file_mode)
else:
self.single_file_download(from_info, to_info, name, no_progress_bar, file_mode)
def single_file_download(self, from_info, to_info, name, no_progress_bar, file_mode):
logger.debug("Downloading '{}' to '{}'".format(from_info, to_info))
name = name or to_info.name
makedirs(to_info.parent, exist_ok=True, mode=dir_mode)
tmp_file = tmp_fname(to_info)
try:
@@ -567,6 +576,7 @@ class RemoteBASE(object):
return 0
def open(self, path_info, mode="r", encoding=None):
if hasattr(self, "_generate_download_url"):
get_url = partial(self._generate_download_url, path_info)