ensure_open_tarfile

ensure_open_tarfile(key, *subkeys, url, inner_path, name=None, force=False, download_kwargs=None, mode='r', open_kwargs=None)[source]

Ensure a tar file is downloaded and open a file inside it.

Parameters:
  • key (str) – 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 (str) – A sequence of additional strings to join. If none are given, returns the directory for this module.

  • url (str) – The URL to download.

  • inner_path (str) – The relative path to the file inside the archive

  • name (Optional[str]) – 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 (bool) – Should the download be done again, even if the path already exists? Defaults to false.

  • download_kwargs (Optional[Mapping[str, Any]]) – Keyword arguments to pass through to pystow.utils.download().

  • mode (str) – The read mode, passed to tarfile.open()

  • open_kwargs (Optional[Mapping[str, Any]]) – Additional keyword arguments passed to tarfile.open()

Yields:

An open file object

Return type:

Iterator[IO]