A contextmanager for zip files. Passes through positional and kwargs to zipfile.ZipFile.
(
path, # type: Text
*args, # type: Any
**kwargs # type: Any
)
| 499 | |
| 500 | @contextlib.contextmanager |
| 501 | def open_zip( |
| 502 | path, # type: Text |
| 503 | *args, # type: Any |
| 504 | **kwargs # type: Any |
| 505 | ): |
| 506 | # type: (...) -> Iterator[ZipFileEx] |
| 507 | """A contextmanager for zip files. |
| 508 | |
| 509 | Passes through positional and kwargs to zipfile.ZipFile. |
| 510 | """ |
| 511 | |
| 512 | # allowZip64=True is the default in Python 3.4+ but not in 2.7. We uniformly enable Zip64 |
| 513 | # extensions across all Pex supported Pythons. |
| 514 | kwargs.setdefault("allowZip64", True) |
| 515 | |
| 516 | with contextlib.closing(ZipFileEx(path, *args, **kwargs)) as zip_fp: |
| 517 | yield zip_fp |
| 518 | |
| 519 | |
| 520 | def deterministic_walk(*args, **kwargs): |