Better image filename handling
This commit is contained in:
parent
97e4501427
commit
9299909e2f
4
app.py
4
app.py
|
@ -345,13 +345,15 @@ def image_with_cache(qid, image_filename, width):
|
||||||
filename = f'cache/{qid}_{width}_image.json'
|
filename = f'cache/{qid}_{width}_image.json'
|
||||||
detail = json.load(open(filename)) if os.path.exists(filename) else {}
|
detail = json.load(open(filename)) if os.path.exists(filename) else {}
|
||||||
|
|
||||||
|
image_filename = image_filename.replace('_', ' ')
|
||||||
|
|
||||||
# The image associated with an item can change.
|
# The image associated with an item can change.
|
||||||
# If that happens the detail in the cache will be for the wrong file.
|
# If that happens the detail in the cache will be for the wrong file.
|
||||||
if not detail or image_filename not in detail:
|
if not detail or image_filename not in detail:
|
||||||
detail = commons.image_detail([image_filename], thumbwidth=width)
|
detail = commons.image_detail([image_filename], thumbwidth=width)
|
||||||
json.dump(detail, open(filename, 'w'), indent=2)
|
json.dump(detail, open(filename, 'w'), indent=2)
|
||||||
|
|
||||||
return detail[image_filename]
|
return detail.get(image_filename)
|
||||||
|
|
||||||
def existing_depicts_from_entity(entity):
|
def existing_depicts_from_entity(entity):
|
||||||
if 'P180' not in entity['claims']:
|
if 'P180' not in entity['claims']:
|
||||||
|
|
Loading…
Reference in a new issue