From 5868810ddc0a32836617bd811a59dc44e206c138 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 4 Mar 2020 09:06:54 +0000 Subject: [PATCH] Refactor. --- app.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index ee3de37..20f3715 100755 --- a/app.py +++ b/app.py @@ -515,11 +515,10 @@ def get_labels_db(keys): def build_other_set(entity): other_items = set() for key in find_more_props.keys(): - if key not in entity['claims']: - continue - for claim in entity['claims'][key]: - if 'datavalue' in claim['mainsnak']: - other_items.add(claim['mainsnak']['datavalue']['value']['id']) + for claim in entity['claims'].get(key, []): + if 'datavalue' not in claim['mainsnak']: + continue + other_items.add(claim['mainsnak']['datavalue']['value']['id']) return other_items def get_other(entity):