File diff 08073f752bc8 → 351811bb30b1
oxrlib/loaders.py
Show inline comments
...
 
@@ -20,6 +20,9 @@ class FileCache(cache.CacheBase):
 
    def open(self, path):
 
        return self.CacheFile(path)
 

	
 
    def is_cache(self):
 
        return True
 

	
 

	
 
class OXRAPIRequest:
 
    DEFAULT_API_ROOT = 'https://openexchangerates.org/api/'
...
 
@@ -30,6 +33,9 @@ class OXRAPIRequest:
 
        self.app_id = app_id
 
        self.open_url = open_func
 

	
 
    def is_cache(self):
 
        return False
 

	
 
    def _get_response_encoding(self, response, default=None):
 
        try:
 
            content_type = response.getheader('Content-Type', 'application/json')
...
 
@@ -69,9 +75,11 @@ class OXRAPIRequest:
 
class LoaderChain:
 
    def __init__(self):
 
        self.loaders = []
 
        self.can_cache = False
 

	
 
    def add_loader(self, loader):
 
        self.loaders.append(loader)
 
        self.can_cache = self.can_cache or loader.is_cache()
 

	
 
    def _wrap_load_method(orig_func):
 
        @functools.wraps(orig_func)
...
 
@@ -93,3 +101,6 @@ class LoaderChain:
 
    @_wrap_load_method
 
    def historical(self, date, base):
 
        pass
 

	
 
    def should_cache(self):
 
        return self.can_cache and self.used_loader and not self.used_loader.is_cache()