Make data-finding safe

This commit is contained in:
Matthias 2019-12-25 10:21:30 +01:00
parent f8b8b9ac63
commit ef0fcb0e0f

View File

@ -19,8 +19,11 @@ class JsonDataHandler(IDataHandler):
""" """
Returns a list of all pairs available in this datadir Returns a list of all pairs available in this datadir
""" """
return [re.search(r'^(\S+)(?=\-' + timeframe + '.json)', p.name)[0].replace('_', ' /')
_tmp = [re.search(r'^(\S+)(?=\-' + timeframe + '.json)', p.name)
for p in datadir.glob(f"*{timeframe}.{cls._get_file_extension()}")] for p in datadir.glob(f"*{timeframe}.{cls._get_file_extension()}")]
# Check if regex found something and only return these results
return [match[0].replace('_', ' /') for match in _tmp if match]
def ohlcv_store(self, timeframe: str, data: DataFrame): def ohlcv_store(self, timeframe: str, data: DataFrame):
""" """
@ -54,8 +57,10 @@ class JsonDataHandler(IDataHandler):
""" """
Returns a list of all pairs available in this datadir Returns a list of all pairs available in this datadir
""" """
return [re.search(r'^(\S+)(?=\-trades.json)', p.name)[0].replace('_', '/') _tmp = [re.search(r'^(\S+)(?=\-trades.json)', p.name)
for p in datadir.glob(f"*trades.{cls._get_file_extension()}")] for p in datadir.glob(f"*trades.{cls._get_file_extension()}")]
# Check if regex found something and only return these results to avoid exceptions.
return [match[0].replace('_', ' /') for match in _tmp if match]
def trades_store(self, data: List[Dict]): def trades_store(self, data: List[Dict]):
""" """