ensure_json_bz2
- ensure_json_bz2(key, *subkeys, url, name=None, force=False, download_kwargs=None, open_kwargs=None, json_load_kwargs=None)[source]
Download BZ2-compressed JSON and open with
json
.- Parameters:
key (
str
) – The module namesubkeys (
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 topystow.utils.download()
.open_kwargs (
Optional
[Mapping
[str
,Any
]]) – Additional keyword arguments passed tobz2.open()
json_load_kwargs (
Optional
[Mapping
[str
,Any
]]) – Keyword arguments to pass through tojson.load()
.
- Return type:
- 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)