@@ -34,8 +34,8 @@ class FileDownloadProxy:
3434 def __init__ (
3535 self ,
3636 auth : keystoneauth1 .session .Session ,
37- chunk_size = 128 * 1024
38- ):
37+ chunk_size : int = 128 * 1024
38+ ) -> None :
3939 """."""
4040 # Establish a queue for the proxied file parts
4141 # Total queue size 128 * 256 * 1024 = 32MiB for now
@@ -103,7 +103,7 @@ def download_into_queue(
103103 project : str ,
104104 container : str ,
105105 object_name : str
106- ):
106+ ) -> None :
107107 """Download object chunks from stream into the queue."""
108108 print (f"""
109109 Downloading from project { project } ,
@@ -159,7 +159,7 @@ async def a_begin_download(
159159 project : str ,
160160 container : str ,
161161 object_name : str
162- ):
162+ ) -> None :
163163 """Begin the download process."""
164164 self .begin_download (
165165 project ,
@@ -172,7 +172,7 @@ def begin_download(
172172 project : str ,
173173 container : str ,
174174 object_name : str
175- ):
175+ ) -> None :
176176 """Begin the download process."""
177177 self .t_dload = threading .Thread (
178178 target = self .download_into_queue ,
@@ -188,7 +188,7 @@ def begin_download(
188188 async def a_write_to_response (
189189 self ,
190190 resp : aiohttp .web .StreamResponse
191- ):
191+ ) -> None :
192192 """Get the response serving the file."""
193193 while True :
194194 chunk = await self .a_read ()
@@ -207,7 +207,7 @@ def __init__(
207207 project : str ,
208208 container : str ,
209209 object_name : str
210- ):
210+ ) -> None :
211211 """."""
212212 # Initialize the download class
213213 self .dload = FileDownloadProxy (auth )
@@ -222,7 +222,7 @@ def get_dload(self) -> FileDownloadProxy:
222222 """Return the specific download instance."""
223223 return self .dload
224224
225- def begin_download (self ):
225+ def begin_download (self ) -> None :
226226 """Begin download and block until received headers."""
227227 self .dload .begin_download (
228228 self .project ,
@@ -258,7 +258,7 @@ class TarQueueWrapper:
258258
259259 def __init__ (
260260 self
261- ):
261+ ) -> None :
262262 """."""
263263 self .q : queue .Queue = queue .Queue (
264264 maxsize = int (
@@ -269,13 +269,13 @@ def __init__(
269269 def write (
270270 self ,
271271 payload : bytes = None
272- ):
272+ ) -> None :
273273 """Emulate BytesIO write function to be used with tarfile."""
274274 self .q .put (payload )
275275
276276 def read (
277277 self
278- ):
278+ ) -> bytes :
279279 """Read next chunk."""
280280 return self .q .get ()
281281
@@ -287,7 +287,7 @@ def get_q(
287287
288288 async def a_read (
289289 self
290- ):
290+ ) -> bytes :
291291 """Asynchronously read next chunk."""
292292 while True :
293293 try :
@@ -304,8 +304,8 @@ def __init__(
304304 auth : keystoneauth1 .session .Session ,
305305 project : str ,
306306 container : str ,
307- chunk_size = 128 * 1024
308- ):
307+ chunk_size : int = 128 * 1024
308+ ) -> None :
309309 """."""
310310 self .auth = auth
311311 self .download_queue : queue .Queue = queue .Queue (
@@ -411,7 +411,7 @@ def _parse_archive_fs(
411411
412412 def get_object_listing (
413413 self ,
414- ):
414+ ) -> None :
415415 """Synchronize the list of objects to download."""
416416 with requests .get (
417417 generate_download_url (
@@ -429,8 +429,8 @@ def get_object_listing(
429429
430430 def sync_folders (
431431 self ,
432- fs
433- ):
432+ fs : dict
433+ ) -> None :
434434 """Sycnhronize the folders into the tar archive."""
435435 if self .archive :
436436 for i in fs :
@@ -440,15 +440,15 @@ def sync_folders(
440440
441441 def download_init (
442442 self ,
443- ):
443+ ) -> None :
444444 """Create download init."""
445445 self .download_init_loop (self .fs )
446446 self .download_queue .put (None )
447447
448448 def download_init_loop (
449449 self ,
450- fs
451- ):
450+ fs : dict
451+ ) -> None :
452452 """Loop to run for initializing downloads."""
453453 if self .archive :
454454 for i in fs :
@@ -472,7 +472,7 @@ def download_init_loop(
472472
473473 def tar_archiving_loop (
474474 self ,
475- ):
475+ ) -> None :
476476 """Loop to run for initializing tarballing."""
477477 while True :
478478 next_file = self .download_queue .get ()
@@ -502,20 +502,20 @@ def tar_archiving_loop(
502502
503503 async def a_begin_container_download (
504504 self ,
505- ):
505+ ) -> None :
506506 """Begin the operation for downloading a whole container."""
507507 self .begin_container_download ()
508508
509509 def begin_container_download (
510510 self ,
511- ):
511+ ) -> None :
512512 """Begin the operation for downloading a whole container."""
513513 self .get_object_listing ()
514514
515515 self .archive = tarfile .open (
516516 name = self .container + ".tar" ,
517517 mode = "w|" ,
518- fileobj = self .output_queue
518+ fileobj = self .output_queue # type:ignore
519519 )
520520
521521 self .sync_folders (self .fs )
@@ -535,7 +535,7 @@ def begin_container_download(
535535 async def a_write_to_response (
536536 self ,
537537 response : aiohttp .web .StreamResponse
538- ):
538+ ) -> None :
539539 """Write the tarball into the response."""
540540 while True :
541541 chunk = await self .output_queue .a_read ()
0 commit comments