Commit 796cb9a3 authored by Christophe Benz's avatar Christophe Benz

Remove cache dir for schemas

parent f75914a0
......@@ -104,7 +104,7 @@ schemas_config = {
]
},
}
ValidatorHelper.init(schemas_config, Path('/tmp'))
ValidatorHelper.init(schemas_config)
# Flask things
app = Flask(__name__)
......
......@@ -20,10 +20,9 @@ class ValidatorHelper:
schema_dict = {}
@classmethod
def init(cls, schema_info, cache_dir: Path):
def init(cls, schema_info):
""" Register and download schema and custom_checks info """
cls.schema_dict = {}
cls.cache_dir = cache_dir
for code in schema_info:
print('Downloading schema {}'.format(code))
schema = schema_info[code].copy()
......@@ -41,19 +40,7 @@ class ValidatorHelper:
@classmethod
def json_download(cls, url, filename):
""" Download url content as JSON """
if cls.cache_dir is None:
return requests.get(url).json()
cache_file = cls.cache_dir / filename
if cache_file.exists():
with cache_file.open('rt', encoding='utf-8') as fd:
return json.load(fd)
else:
data = requests.get(url).json()
with cache_file.open("wt", encoding='utf-8') as fd:
json.dump(data, fd, ensure_ascii=False, sort_keys=True, indent=2)
return data
return requests.get(url).json()
@classmethod
def schema_exist(cls, schema_code):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment