Skip to content

Commit 77196b3

Browse files
committed
Apply format
1 parent d8fb4ab commit 77196b3

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

gdown/__main__.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,8 @@ def main():
106106
"-c",
107107
dest="continue_",
108108
action="store_true",
109-
help=(
110-
"resume getting partially-downloaded files "
111-
"from their download tempfile, "
112-
"and skip fully transferred files"
113-
),
109+
help="resume getting partially-downloaded files while "
110+
"skipping fully downloaded ones",
114111
)
115112
parser.add_argument(
116113
"--folder",
@@ -200,7 +197,7 @@ def main():
200197
sys.exit(1)
201198
except requests.exceptions.ProxyError as e:
202199
print(
203-
"Failed to use proxy:\n\n{}\n\n" "Please check your proxy settings.".format(
200+
"Failed to use proxy:\n\n{}\n\nPlease check your proxy settings.".format(
204201
indent("\n".join(textwrap.wrap(str(e))), prefix="\t")
205202
),
206203
file=sys.stderr,

gdown/download.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from .parse_url import parse_url
2020

2121
CHUNK_SIZE = 512 * 1024 # 512KB
22-
TEMPFILE_SUFFIX = ".part"
2322
home = osp.expanduser("~")
2423

2524

@@ -153,9 +152,7 @@ def download(
153152
fuzzy: bool
154153
Fuzzy extraction of Google Drive's file Id. Default is False.
155154
resume: bool
156-
Resume interrupted transfers.
157-
Completed output files will be skipped.
158-
Partial tempfiles will be reused, if the transfer is incomplete.
155+
Resume interrupted downloads while skipping completed ones.
159156
Default is False.
160157
format: str, optional
161158
Format of Google Docs, Spreadsheets and Slides. Default is:
@@ -298,19 +295,14 @@ def download(
298295
output = osp.join(output, filename_from_url)
299296

300297
if output_is_path:
301-
302-
# Shortcut any 100% transfers to avoid excessive GETs,
303-
# when it's reasonable to assume that gdown would've been
304-
# using tempfiles and atomic renames before.
305298
if resume and os.path.isfile(output):
306299
if not quiet:
307-
print(f"resume: already have {output}")
300+
print(f"Skipping already downloaded file {output}", file=sys.stderr)
308301
return output
309302

310-
# Alternatively, resume mode can reuse partial tmp_files.
311303
existing_tmp_files = []
312304
for file in os.listdir(osp.dirname(output) or "."):
313-
if file.startswith(osp.basename(output)) and file.endswith(TEMPFILE_SUFFIX):
305+
if file.startswith(osp.basename(output)):
314306
existing_tmp_files.append(osp.join(osp.dirname(output), file))
315307
if resume and existing_tmp_files:
316308
if len(existing_tmp_files) != 1:
@@ -328,13 +320,12 @@ def download(
328320
)
329321
return
330322
tmp_file = existing_tmp_files[0]
331-
# Perhaps it should select the biggest one?
332323
else:
333324
resume = False
334325
# mkstemp is preferred, but does not work on Windows
335326
# https://github.com/wkentaro/gdown/issues/153
336327
tmp_file = tempfile.mktemp(
337-
suffix=TEMPFILE_SUFFIX,
328+
suffix=tempfile.template,
338329
prefix=osp.basename(output),
339330
dir=osp.dirname(output),
340331
)

gdown/download_folder.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,12 @@ def download_folder(
313313
GoogleDriveFileToDownload(id=id, path=path, local_path=local_path)
314314
)
315315
else:
316-
# Shortcut existing 100% transfers here,
317-
# instead of invoking download(),
318-
# to avoid making unnecessary requests.
319316
if resume and os.path.isfile(local_path):
320-
# already downloaded this file
321317
if not quiet:
322-
print(f"resume: already have {local_path}")
318+
print(
319+
f"Skipping already downloaded file {local_path}",
320+
file=sys.stderr,
321+
)
323322
files.append(local_path)
324323
continue
325324

0 commit comments

Comments
 (0)