From 9299909e2f74dacf96cd80bcd0bb18d79d34d834 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 30 Jun 2020 09:00:58 +0100 Subject: [PATCH] Better image filename handling --- app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 73e2d14..eef62f2 100755 --- a/app.py +++ b/app.py @@ -345,13 +345,15 @@ def image_with_cache(qid, image_filename, width): filename = f'cache/{qid}_{width}_image.json' detail = json.load(open(filename)) if os.path.exists(filename) else {} + image_filename = image_filename.replace('_', ' ') + # The image associated with an item can change. # If that happens the detail in the cache will be for the wrong file. if not detail or image_filename not in detail: detail = commons.image_detail([image_filename], thumbwidth=width) json.dump(detail, open(filename, 'w'), indent=2) - return detail[image_filename] + return detail.get(image_filename) def existing_depicts_from_entity(entity): if 'P180' not in entity['claims']: