File diff 4cbd89099230 → eba27c16ae78
oxrlib/loaders.py
Show inline comments
...
 
@@ -4,19 +4,20 @@ import io
 
import urllib.request
 
import urllib.parse
 

	
 
from . import errors
 
from . import cache, errors
 

	
 
class FileCache:
 
    def __init__(self, dir_path, filename_pattern):
 
        self.dir_path = dir_path
 
        self.pattern = filename_pattern
 
class ReadCacheFile(cache.CacheFileBase):
 
    ERRORS_MAP = [
 
        (FileNotFoundError, errors.LoaderNoDataError),
 
        (OSError, errors.LoaderSourceError),
 
    ]
 

	
 
    def historical(self, date, base):
 
        path = self.dir_path / self.pattern.format(date=date.isoformat(), base=base)
 
        try:
 
            return path.open()
 
        except FileNotFoundError as error:
 
            raise errors.LoaderNoDataError(path) from error
 

	
 
class FileCache(cache.CacheBase):
 
    ConfigurationError = errors.CacheLoaderConfigurationError
 

	
 
    def open(self, path):
 
        return ReadCacheFile(path)
 

	
 

	
 
class OXRAPIRequest: