9
9
import os
10
10
import shutil
11
11
import sys
12
- from typing import BinaryIO , Callable , Dict , List , Optional
12
+ from typing import Any , BinaryIO , Callable , Dict , List , Optional
13
13
14
14
import llnl .url
15
15
from llnl .util import tty
@@ -157,6 +157,10 @@ def _system_gunzip(archive_file: str) -> str:
157
157
return destination_abspath
158
158
159
159
160
+ def _do_nothing (archive_file : str ) -> None :
161
+ return None
162
+
163
+
160
164
def _unzip (archive_file : str ) -> str :
161
165
"""Returns path to extracted zip archive. Extract Zipfile, searching for unzip system
162
166
executable. If unavailable, search for 'tar' executable on system and use instead.
@@ -283,26 +287,27 @@ def decompressor_for(path: str, extension: Optional[str] = None):
283
287
return decompressor_for_nix (extension )
284
288
285
289
286
- def decompressor_for_nix (extension : str ) -> Callable [[str ], str ]:
290
+ def decompressor_for_nix (extension : str ) -> Callable [[str ], Any ]:
287
291
"""Returns a function pointer to appropriate decompression algorithm based on extension type
288
292
and unix specific considerations i.e. a reasonable expectation system utils like gzip, bzip2,
289
293
and xz are available
290
294
291
295
Args:
292
296
extension: path of the archive file requiring decompression
293
297
"""
294
- extension_to_decompressor : Dict [str , Callable [[str ], str ]] = {
298
+ extension_to_decompressor : Dict [str , Callable [[str ], Any ]] = {
295
299
"zip" : _unzip ,
296
300
"gz" : _gunzip ,
297
301
"bz2" : _bunzip2 ,
298
302
"Z" : _system_unZ , # no builtin support for .Z files
299
303
"xz" : _lzma_decomp ,
304
+ "whl" : _do_nothing ,
300
305
}
301
306
302
307
return extension_to_decompressor .get (extension , _system_untar )
303
308
304
309
305
- def _determine_py_decomp_archive_strategy (extension : str ) -> Optional [Callable [[str ], str ]]:
310
+ def _determine_py_decomp_archive_strategy (extension : str ) -> Optional [Callable [[str ], Any ]]:
306
311
"""Returns appropriate python based decompression strategy
307
312
based on extension type"""
308
313
extension_to_decompressor : Dict [str , Callable [[str ], str ]] = {
@@ -313,7 +318,7 @@ def _determine_py_decomp_archive_strategy(extension: str) -> Optional[Callable[[
313
318
return extension_to_decompressor .get (extension , None )
314
319
315
320
316
- def decompressor_for_win (extension : str ) -> Callable [[str ], str ]:
321
+ def decompressor_for_win (extension : str ) -> Callable [[str ], Any ]:
317
322
"""Returns a function pointer to appropriate decompression
318
323
algorithm based on extension type and Windows specific considerations
319
324
@@ -323,7 +328,7 @@ def decompressor_for_win(extension: str) -> Callable[[str], str]:
323
328
and files as Python does not provide support for the UNIX compress algorithm
324
329
"""
325
330
extension = llnl .url .expand_contracted_extension (extension )
326
- extension_to_decompressor : Dict [str , Callable [[str ], str ]] = {
331
+ extension_to_decompressor : Dict [str , Callable [[str ], Any ]] = {
327
332
# Windows native tar can handle .zip extensions, use standard unzip method
328
333
"zip" : _unzip ,
329
334
# if extension is standard tarball, invoke Windows native tar
@@ -333,6 +338,7 @@ def decompressor_for_win(extension: str) -> Callable[[str], str]:
333
338
# detected
334
339
"Z" : _system_unZ ,
335
340
"xz" : _lzma_decomp ,
341
+ "whl" : _do_nothing ,
336
342
}
337
343
338
344
decompressor = extension_to_decompressor .get (extension )
0 commit comments