ensure_pickle

ensure_pickle(key, *subkeys, url, name=None, force=False, download_kwargs=None, mode='rb', open_kwargs=None, pickle_load_kwargs=None)[source]

Download a pickle file and open with pickle.

Parameters:
  • key (str) – The module name

  • 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.

  • 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 open()

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

  • pickle_load_kwargs (Optional[Mapping[str, Any]]) – Keyword arguments to pass through to pickle.load().

Return type:

Any

Returns:

Any object