From 1a7872b136bbaad24b2df2b7b096e6ecec52fe15 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 14 Oct 2019 20:04:04 +0100 Subject: [PATCH] really fix. --- app.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 5108ad6..eb21540 100755 --- a/app.py +++ b/app.py @@ -316,11 +316,13 @@ def existing_depicts_from_entity(entity): def get_institution(entity, other): if 'P276' in entity['claims']: - location = wikibase.first_datavalue(entity, 'P276')['id'] - return other[location] - elif 'P195' in entity['claims']: - collection = wikibase.first_datavalue(entity, 'P195')['id'] - return other[collection] + location = wikibase.first_datavalue(entity, 'P276') + if location: + return other[location['id']] + if 'P195' in entity['claims']: + collection = wikibase.first_datavalue(entity, 'P195') + if collection: + return other[collection['id']] @app.route("/item/Q") def item_page(item_id):