def __init__(self, data_directory: FilePath) -> None: self.prefix = 'https://min-api.cryptocompare.com/data/' self.data_directory = data_directory self.price_history: Dict[PairCacheKey, PriceHistoryData] = dict() self.price_history_file: Dict[PairCacheKey, FilePath] = dict() # Check the data folder and remember the filenames of any cached history prefix = os.path.join(self.data_directory, 'price_history_') prefix = prefix.replace('\\', '\\\\') regex = re.compile(prefix + r'(.*)\.json') files_list = glob.glob(prefix + '*.json') for file_ in files_list: file_ = FilePath(file_.replace('\\\\', '\\')) match = regex.match(file_) assert match cache_key = PairCacheKey(match.group(1)) self.price_history_file[cache_key] = file_
def __init__(self, data_directory: FilePath, database: Optional[DBHandler]) -> None: super().__init__(database=database, service_name=ExternalService.CRYPTOCOMPARE) self.data_directory = data_directory self.price_history: Dict[PairCacheKey, PriceHistoryData] = {} self.price_history_file: Dict[PairCacheKey, FilePath] = {} self.session = requests.session() self.session.headers.update({'User-Agent': 'rotkehlchen'}) # Check the data folder and remember the filenames of any cached history prefix = os.path.join(self.data_directory, 'price_history_') prefix = prefix.replace('\\', '\\\\') regex = re.compile(prefix + r'(.*)\.json') files_list = glob.glob(prefix + '*.json') for file_ in files_list: file_ = FilePath(file_.replace('\\\\', '\\')) match = regex.match(file_) assert match cache_key = PairCacheKey(match.group(1)) self.price_history_file[cache_key] = file_