@@ -385,11 +385,8 @@ def _download_file(self, url, local_filepath, timeout=None, auth=None,
385
385
if length is not None :
386
386
statinfo = os .stat (local_filepath )
387
387
if statinfo .st_size != length :
388
- log .warning ("Found cached file {0} with size {1} that is "
389
- "different from expected size {2}"
390
- .format (local_filepath ,
391
- statinfo .st_size ,
392
- length ))
388
+ log .warning (f"Found cached file { local_filepath } with size { statinfo .st_size } "
389
+ f"that is different from expected size { length } " )
393
390
open_mode = 'wb'
394
391
else :
395
392
log .info ("Found cached file {0} with expected size {1}."
@@ -421,20 +418,16 @@ def _download_file(self, url, local_filepath, timeout=None, auth=None,
421
418
else :
422
419
progress_stream = io .StringIO ()
423
420
424
- with ProgressBarOrSpinner (
425
- length , ('Downloading URL {0} to {1} ...'
426
- .format (url , local_filepath )),
427
- file = progress_stream ) as pb :
421
+ with ProgressBarOrSpinner (length , f'Downloading URL { url } to { local_filepath } ...' ,
422
+ file = progress_stream ) as pb :
428
423
with open (local_filepath , open_mode ) as f :
429
424
for block in response .iter_content (blocksize ):
430
425
f .write (block )
431
426
bytes_read += blocksize
432
427
if length is not None :
433
- pb .update (bytes_read if bytes_read <= length else
434
- length )
428
+ pb .update (bytes_read if bytes_read <= length else length )
435
429
else :
436
430
pb .update (bytes_read )
437
-
438
431
response .close ()
439
432
return response
440
433
0 commit comments