ensure_json_bz2
- ensure_json_bz2(key: str, *subkeys: str, url: str, name: str | None = None, force: bool = False, version: None | str | Callable[[], str | None] = None, download_kwargs: DownloadKwargs | None = None, open_kwargs: Mapping[str, Any] | None = None, json_load_kwargs: Mapping[str, Any] | None = None) Any[source]
Download BZ2-compressed JSON and open with
json.- Parameters:
key – The module name
subkeys – A sequence of additional strings to join. If none are given, returns the directory for this module.
url – The URL to download.
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.
version – The optional version, or no-argument callable that returns an optional version. This is prepended before the subkeys.
download_kwargs – Keyword arguments to pass through to
pystow.utils.download().open_kwargs – Additional keyword arguments passed to
bz2.open()json_load_kwargs – Keyword arguments to pass through to
json.load().
- Returns:
A JSON object (list, dict, etc.)
Example usage:
>>> import pystow >>> url = "https://github.com/hetio/hetionet/raw/master/hetnet/json/hetionet-v1.0.json.bz2" >>> hetionet = pystow.ensure_json_bz2("bio", "hetionet", "1.0", url=url)