# Path: OSMPythonTools/cachingStrategy/strategy.py
# class CachingStrategy():
#     __strategy = JSON()
#     @classmethod
#     def use(cls, strategy, **kwargs):
#         cls.__strategy.close()
#         cls.__strategy = strategy(**kwargs)
#         return cls.__strategy
#     @classmethod
#     def get(cls, key):
#         return cls.__strategy.get(key)
#     @classmethod
#     def set(cls, key, value):
#         cls.__strategy.set(key, value)


import datetime
import hashlib
import os
import time
import ujson
import urllib.request
import OSMPythonTools
from OSMPythonTools.cachingStrategy import CachingStrategy
            if 'version' not in data or 'response' not in data or 'timestamp' not in data:
                data = {
                    'version': '0.1',
                    'response': data,
                    'timestamp': None,
                }
        elif onlyCached:
            OSMPythonTools.logger.error('[' + self._prefix + '] data not cached: ' + queryString)
            return None
        elif shallow:
            data = {
                'version': '1.0',
                'response': shallow,
                'timestamp': None,
            }
        else:
            makeDownload = True
            OSMPythonTools.logger.warning('[' + self._prefix + '] downloading data: ' + queryString)
            if self._waitForReady() == None:
                if self.__lastQuery and self.__waitBetweenQueries and time.time() - self.__lastQuery < self.__waitBetweenQueries:
                    time.sleep(self.__waitBetweenQueries - time.time() + self.__lastQuery)
            self.__lastQuery = time.time()
            data = self.__query(queryString, params)
        cacheMetadata = {key: data[key] for key in ['version', 'timestamp']}
        result = self._rawToResult(data['response'], queryString, params, kwargs, cacheMetadata=cacheMetadata, shallow=shallow)
        if not self._isValid(result):
            msg = '[' + self._prefix + '] error in result (' + key + '): ' + queryString
            OSMPythonTools.logger.exception(msg)
            raise(Exception(msg))
        if makeDownload:

# Path: OSMPythonTools/cachingStrategy/strategy.py
# class CachingStrategy():
#     __strategy = JSON()
#     @classmethod
#     def use(cls, strategy, **kwargs):
#         cls.__strategy.close()
#         cls.__strategy = strategy(**kwargs)
#         return cls.__strategy
#     @classmethod
#     def get(cls, key):
#         return cls.__strategy.get(key)
#     @classmethod
#     def set(cls, key, value):
#         cls.__strategy.set(key, value)


# Path: OSMPythonTools/internal/cacheObject.py
import datetime
import hashlib
import os
import time
import ujson
import urllib.request
import OSMPythonTools
from OSMPythonTools.cachingStrategy import CachingStrategy

            if 'version' not in data or 'response' not in data or 'timestamp' not in data:
                data = {
                    'version': '0.1',
                    'response': data,
                    'timestamp': None,
                }
        elif onlyCached:
            OSMPythonTools.logger.error('[' + self._prefix + '] data not cached: ' + queryString)
            return None
        elif shallow:
            data = {
                'version': '1.0',
                'response': shallow,
                'timestamp': None,
            }
        else:
            makeDownload = True
            OSMPythonTools.logger.warning('[' + self._prefix + '] downloading data: ' + queryString)
            if self._waitForReady() == None:
                if self.__lastQuery and self.__waitBetweenQueries and time.time() - self.__lastQuery < self.__waitBetweenQueries:
                    time.sleep(self.__waitBetweenQueries - time.time() + self.__lastQuery)
            self.__lastQuery = time.time()
            data = self.__query(queryString, params)
        cacheMetadata = {key: data[key] for key in ['version', 'timestamp']}
        result = self._rawToResult(data['response'], queryString, params, kwargs, cacheMetadata=cacheMetadata, shallow=shallow)
        if not self._isValid(result):
            msg = '[' + self._prefix + '] error in result (' + key + '): ' + queryString
            OSMPythonTools.logger.exception(msg)
            raise(Exception(msg))
        if makeDownload:

            CachingStrategy.set(key, data)