@@ -34,8 +34,8 @@ class FileDownloadProxy:
34
34
def __init__ (
35
35
self ,
36
36
auth : keystoneauth1 .session .Session ,
37
- chunk_size = 128 * 1024
38
- ):
37
+ chunk_size : int = 128 * 1024
38
+ ) -> None :
39
39
"""."""
40
40
# Establish a queue for the proxied file parts
41
41
# Total queue size 128 * 256 * 1024 = 32MiB for now
@@ -103,7 +103,7 @@ def download_into_queue(
103
103
project : str ,
104
104
container : str ,
105
105
object_name : str
106
- ):
106
+ ) -> None :
107
107
"""Download object chunks from stream into the queue."""
108
108
print (f"""
109
109
Downloading from project { project } ,
@@ -159,7 +159,7 @@ async def a_begin_download(
159
159
project : str ,
160
160
container : str ,
161
161
object_name : str
162
- ):
162
+ ) -> None :
163
163
"""Begin the download process."""
164
164
self .begin_download (
165
165
project ,
@@ -172,7 +172,7 @@ def begin_download(
172
172
project : str ,
173
173
container : str ,
174
174
object_name : str
175
- ):
175
+ ) -> None :
176
176
"""Begin the download process."""
177
177
self .t_dload = threading .Thread (
178
178
target = self .download_into_queue ,
@@ -188,7 +188,7 @@ def begin_download(
188
188
async def a_write_to_response (
189
189
self ,
190
190
resp : aiohttp .web .StreamResponse
191
- ):
191
+ ) -> None :
192
192
"""Get the response serving the file."""
193
193
while True :
194
194
chunk = await self .a_read ()
@@ -207,7 +207,7 @@ def __init__(
207
207
project : str ,
208
208
container : str ,
209
209
object_name : str
210
- ):
210
+ ) -> None :
211
211
"""."""
212
212
# Initialize the download class
213
213
self .dload = FileDownloadProxy (auth )
@@ -222,7 +222,7 @@ def get_dload(self) -> FileDownloadProxy:
222
222
"""Return the specific download instance."""
223
223
return self .dload
224
224
225
- def begin_download (self ):
225
+ def begin_download (self ) -> None :
226
226
"""Begin download and block until received headers."""
227
227
self .dload .begin_download (
228
228
self .project ,
@@ -258,7 +258,7 @@ class TarQueueWrapper:
258
258
259
259
def __init__ (
260
260
self
261
- ):
261
+ ) -> None :
262
262
"""."""
263
263
self .q : queue .Queue = queue .Queue (
264
264
maxsize = int (
@@ -269,13 +269,13 @@ def __init__(
269
269
def write (
270
270
self ,
271
271
payload : bytes = None
272
- ):
272
+ ) -> None :
273
273
"""Emulate BytesIO write function to be used with tarfile."""
274
274
self .q .put (payload )
275
275
276
276
def read (
277
277
self
278
- ):
278
+ ) -> bytes :
279
279
"""Read next chunk."""
280
280
return self .q .get ()
281
281
@@ -287,7 +287,7 @@ def get_q(
287
287
288
288
async def a_read (
289
289
self
290
- ):
290
+ ) -> bytes :
291
291
"""Asynchronously read next chunk."""
292
292
while True :
293
293
try :
@@ -304,8 +304,8 @@ def __init__(
304
304
auth : keystoneauth1 .session .Session ,
305
305
project : str ,
306
306
container : str ,
307
- chunk_size = 128 * 1024
308
- ):
307
+ chunk_size : int = 128 * 1024
308
+ ) -> None :
309
309
"""."""
310
310
self .auth = auth
311
311
self .download_queue : queue .Queue = queue .Queue (
@@ -411,7 +411,7 @@ def _parse_archive_fs(
411
411
412
412
def get_object_listing (
413
413
self ,
414
- ):
414
+ ) -> None :
415
415
"""Synchronize the list of objects to download."""
416
416
with requests .get (
417
417
generate_download_url (
@@ -429,8 +429,8 @@ def get_object_listing(
429
429
430
430
def sync_folders (
431
431
self ,
432
- fs
433
- ):
432
+ fs : dict
433
+ ) -> None :
434
434
"""Sycnhronize the folders into the tar archive."""
435
435
if self .archive :
436
436
for i in fs :
@@ -440,15 +440,15 @@ def sync_folders(
440
440
441
441
def download_init (
442
442
self ,
443
- ):
443
+ ) -> None :
444
444
"""Create download init."""
445
445
self .download_init_loop (self .fs )
446
446
self .download_queue .put (None )
447
447
448
448
def download_init_loop (
449
449
self ,
450
- fs
451
- ):
450
+ fs : dict
451
+ ) -> None :
452
452
"""Loop to run for initializing downloads."""
453
453
if self .archive :
454
454
for i in fs :
@@ -472,7 +472,7 @@ def download_init_loop(
472
472
473
473
def tar_archiving_loop (
474
474
self ,
475
- ):
475
+ ) -> None :
476
476
"""Loop to run for initializing tarballing."""
477
477
while True :
478
478
next_file = self .download_queue .get ()
@@ -502,20 +502,20 @@ def tar_archiving_loop(
502
502
503
503
async def a_begin_container_download (
504
504
self ,
505
- ):
505
+ ) -> None :
506
506
"""Begin the operation for downloading a whole container."""
507
507
self .begin_container_download ()
508
508
509
509
def begin_container_download (
510
510
self ,
511
- ):
511
+ ) -> None :
512
512
"""Begin the operation for downloading a whole container."""
513
513
self .get_object_listing ()
514
514
515
515
self .archive = tarfile .open (
516
516
name = self .container + ".tar" ,
517
517
mode = "w|" ,
518
- fileobj = self .output_queue
518
+ fileobj = self .output_queue # type:ignore
519
519
)
520
520
521
521
self .sync_folders (self .fs )
@@ -535,7 +535,7 @@ def begin_container_download(
535
535
async def a_write_to_response (
536
536
self ,
537
537
response : aiohttp .web .StreamResponse
538
- ):
538
+ ) -> None :
539
539
"""Write the tarball into the response."""
540
540
while True :
541
541
chunk = await self .output_queue .a_read ()
0 commit comments