Commit cee72f63 authored by Pierre Dittgen's avatar Pierre Dittgen

Get rid of cachetools dependency

parent 128689fe
Pipeline #1018 failed with stage
in 21 seconds
......@@ -54,7 +54,6 @@ setup(
'backports-datetime-fromisoformat',
'cachecontrol',
'cachetools',
'commonmark',
'ezodf',
'flask',
......
......@@ -9,7 +9,6 @@ import flask
import jinja2
import requests
import tableschema
from cachetools.func import ttl_cache
import opendataschema
......@@ -18,9 +17,16 @@ from . import config
log = logging.getLogger(__name__)
@ttl_cache(maxsize=24, ttl=5*60)
def schema_from_url(url):
return tableschema.Schema(url)
def generate_schema_from_url_func(session):
"""Generates a function that encloses session"""
def schema_from_url(url):
req = session.get(url)
req.raise_for_status()
schema_dict = req.json()
return tableschema.Schema(schema_dict)
return schema_from_url
# And load schema catalogs which urls are found in config.json
......@@ -28,6 +34,7 @@ schema_catalog_map = {}
if config.HOMEPAGE_CONFIG:
log.info("Initializing homepage sections...")
caching_session = cachecontrol.CacheControl(requests.Session())
schema_from_url = generate_schema_from_url_func(caching_session)
for section in config.HOMEPAGE_CONFIG['sections']:
if isinstance(section['catalog'], str) and section['catalog'].startswith('http'):
code = section['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