Add option to return wikibase entities as dict.
This commit is contained in:
parent
5def7e80ad
commit
9688331190
|
@ -43,6 +43,16 @@ def get_entities(ids, **params):
|
||||||
json_data = r.json()
|
json_data = r.json()
|
||||||
return list(json_data['entities'].values())
|
return list(json_data['entities'].values())
|
||||||
|
|
||||||
|
def get_entities_dict(ids, **params):
|
||||||
|
if not ids:
|
||||||
|
return []
|
||||||
|
params = {
|
||||||
|
'action': 'wbgetentities',
|
||||||
|
'ids': '|'.join(ids),
|
||||||
|
**params,
|
||||||
|
}
|
||||||
|
return api_call(params).json()['entities']
|
||||||
|
|
||||||
def get_entity_with_cache(qid):
|
def get_entity_with_cache(qid):
|
||||||
filename = f'cache/{qid}.json'
|
filename = f'cache/{qid}.json'
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
|
|
Loading…
Reference in a new issue