Initialize datahandlers
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from typing import Type
|
||||
|
||||
from pathlib import Path
|
||||
from .idatahandler import IDataHandler
|
||||
|
||||
|
||||
@@ -20,3 +20,17 @@ def get_datahandlerclass(datatype: str) -> Type[IDataHandler]:
|
||||
return JsonGzDataHandler
|
||||
else:
|
||||
raise ValueError(f"No datahandler for datatype {datatype} available.")
|
||||
|
||||
|
||||
def get_datahandler(datadir: Path, data_format: str = None,
|
||||
data_handler: IDataHandler = None) -> IDataHandler:
|
||||
"""
|
||||
:param datadir: Folder to save data
|
||||
:data_format: dataformat to use
|
||||
:data_handler: returns this datahandler if it exists or initializes a new one
|
||||
"""
|
||||
|
||||
if not data_handler:
|
||||
HandlerClass = get_datahandlerclass(data_format or 'json')
|
||||
data_handler = HandlerClass(datadir)
|
||||
return data_handler
|
||||
|
Reference in New Issue
Block a user