From 146b79bde8653d57638c90762dba04744ac8f511 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 29 Sep 2019 19:24:24 +0100 Subject: [PATCH] Bug fix missing datavalue. --- app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 46e991c..fb729d5 100755 --- a/app.py +++ b/app.py @@ -72,8 +72,7 @@ select ?item ?itemLabel ?image ?artist ?artistLabel ?title ?time ?timeprecision ''' find_more_basic_query = ''' -select ?item ?itemLabel ?image ?artist { - SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +select distinct ?item ?image { VALUES ?value { LIST } ?item wdt:P31 wd:Q3305213 . ?item wdt:PID ?value . @@ -570,6 +569,8 @@ def next_page(item_id): values = [] for claim in claims: + if 'datavalue' not in claim['mainsnak']: + continue value = claim['mainsnak']['datavalue']['value'] claim_qid = value['id'] numeric_id = value['numeric-id'] @@ -580,6 +581,9 @@ def next_page(item_id): 'label': other.get(claim_qid), }) + if not values: + continue + qid_list = [v['qid'] for v in values] other_list.append({