From 24a3fa8c5f3e0931b52cfdf6a24bfe035fa9cf31 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 25 Jun 2022 00:58:57 +0200 Subject: don't crash if there is no such relation --- fetch_data.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fetch_data.py b/fetch_data.py index 3c77c78..a0753c4 100755 --- a/fetch_data.py +++ b/fetch_data.py @@ -141,7 +141,14 @@ def query_overpass(relation_ids: Collection[int], with_length: bool): wikidata_lengths = query_lengths_from_wikidata(wikidata_ids()) for rel_id in relation_ids: - rel = all_relations[rel_id] + rel = all_relations.get(rel_id) + if not rel: + # TODO: report 404 in generated data + print( + f'[warning] could not find relation {rel_id}', + file=sys.stderr, + ) + continue data = dict(tags={k: v for k, v in rel['tags'].items() if k in KEYS}) if with_length: -- cgit v1.2.3