From 888610f5fe6499a48f14f9444a1eee565c04d7ff Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 7 Oct 2019 14:23:57 +0100 Subject: [PATCH] Add refresh option to get_entity_with_cache. --- depicts/mediawiki.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depicts/mediawiki.py b/depicts/mediawiki.py index 3887f95..a3ae224 100644 --- a/depicts/mediawiki.py +++ b/depicts/mediawiki.py @@ -53,9 +53,9 @@ def get_entities_dict(ids, **params): } return api_call(params).json()['entities'] -def get_entity_with_cache(qid): +def get_entity_with_cache(qid, refresh=False): filename = f'cache/{qid}.json' - if os.path.exists(filename): + if not refresh and os.path.exists(filename): entity = json.load(open(filename)) else: entity = get_entity(qid)