Add explicit tests for ohlcv regex

This commit is contained in:
Matthias
2021-11-28 14:33:46 +01:00
parent 107e124f60
commit c096c7f5cb
4 changed files with 19 additions and 4 deletions

View File

@@ -30,8 +30,7 @@ class HDF5DataHandler(IDataHandler):
"""
_tmp = [
re.search(
r'^([a-zA-Z_]+(\:[a-zA-Z]{2,}(\-[0-9]{2,})?)?)\-(\d+\S)\-?([a-zA-Z_]*)?(?=.h5)',
p.name
cls._OHLCV_REGEX, p.name
) for p in datadir.glob("*.h5")
]
return [(match[1].replace('_', '/'), match[2], match[3]) for match in _tmp

View File

@@ -23,6 +23,8 @@ logger = logging.getLogger(__name__)
class IDataHandler(ABC):
_OHLCV_REGEX = r'^([a-zA-Z_]+)\-(\d+\S+)(?=\.)'
def __init__(self, datadir: Path) -> None:
self._datadir = datadir

View File

@@ -31,8 +31,7 @@ class JsonDataHandler(IDataHandler):
"""
_tmp = [
re.search(
r'^([a-zA-Z_]+(\:[a-zA-Z]{2,}(\-[0-9]{2,})?)?)\-(\d+\S)\-?([a-zA-Z_]*)?(?=.json)',
p.name
cls._OHLCV_REGEX, p.name
) for p in datadir.glob(f"*.{cls._get_file_extension()}")]
return [(match[1].replace('_', '/'), match[2], match[3]) for match in _tmp
if match and len(match.groups()) > 1]