diff --git a/csv_metadata_quality/check.py b/csv_metadata_quality/check.py index cfa870e..add1c5a 100755 --- a/csv_metadata_quality/check.py +++ b/csv_metadata_quality/check.py @@ -1,3 +1,4 @@ +import os import re from datetime import datetime, timedelta @@ -242,7 +243,11 @@ def agrovoc(field, field_name): # enable transparent request cache with thirty days expiry expire_after = timedelta(days=30) - requests_cache.install_cache("agrovoc-response-cache", expire_after=expire_after) + # Allow overriding the location of the requests cache, just in case we are + # running in an environment where we can't write to the current working di- + # rectory (for example from csv-metadata-quality-web). + REQUESTS_CACHE_DIR = os.environ.get("REQUESTS_CACHE_DIR", ".") + requests_cache.install_cache(f"{REQUESTS_CACHE_DIR}/agrovoc-response-cache", expire_after=expire_after) # prune old cache entries requests_cache.core.remove_expired_responses()