ensure_open_zip
- ensure_open_zip(key: str, *subkeys: str, url: str, inner_path: str, name: str | None = None, force: bool = False, download_kwargs: DownloadKwargs | None = None, mode: Literal['r', 'w', 'rb', 'wb'] = 'r', zipfile_kwargs: Mapping[str, Any] | None = None, open_kwargs: Mapping[str, Any] | None = None) Generator[BinaryIO, None, None][source]
- ensure_open_zip(key: str, *subkeys: str, url: str, inner_path: str, name: str | None = None, force: bool = False, download_kwargs: DownloadKwargs | None = None, mode: Literal['rt', 'wt'] = 'r', zipfile_kwargs: Mapping[str, Any] | None = None, open_kwargs: Mapping[str, Any] | None = None) Generator[TextIO, None, None]
Ensure a file is downloaded then open it with
zipfile.- Parameters:
key – The name of the module. No funny characters. The envvar <key>_HOME where key is uppercased is checked first before using the default home directory.
subkeys – A sequence of additional strings to join. If none are given, returns the directory for this module.
url – The URL to download.
inner_path – The relative path to the file inside the archive
name – Overrides the name of the file at the end of the URL, if given. Also useful for URLs that don’t have proper filenames with extensions.
force – Should the download be done again, even if the path already exists? Defaults to false.
download_kwargs – Keyword arguments to pass through to
pystow.utils.download().mode – The read mode, passed to
zipfile.open()zipfile_kwargs – Additional keyword arguments passed to
zipfile.ZipFileopen_kwargs – Additional keyword arguments passed to
zipfile.open()
- Yields:
An open file object