diff --git a/json_database/hpm.py b/json_database/hpm.py index 81dcd72..4206bdd 100644 --- a/json_database/hpm.py +++ b/json_database/hpm.py @@ -3,13 +3,17 @@ from ovos_utils.xdg_utils import xdg_data_home from typing import Union, Iterable, List from json_database import JsonStorageXDG +from dataclasses import dataclass +@dataclass class JsonDB(AbstractDB): """HiveMind Database implementation using JSON files.""" + name: str = "clients" + subfolder: str = "hivemind-core" - def __init__(self, name="clients", subfolder="hivemind-core"): - self._db = JsonStorageXDG(name, subfolder=subfolder, xdg_folder=xdg_data_home()) + def __post_init__(self): + self._db = JsonStorageXDG(self.name, subfolder=self.subfolder, xdg_folder=xdg_data_home()) LOG.debug(f"json database path: {self._db.path}") def sync(self): diff --git a/setup.py b/setup.py index b77afd0..8d3deed 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,9 @@ def get_description(): return long_description +PLUGIN_ENTRY_POINT = 'hivemind-json-db-plugin=json_database.hpm:JsonDB' + + setup( name='json_database', version=get_version(), @@ -68,6 +71,7 @@ def get_description(): author_email='jarbasai@mailfence.com', install_requires=required('requirements.txt'), description='searchable json database with persistence', + entry_points={'hivemind.database': PLUGIN_ENTRY_POINT}, long_description=get_description(), - long_description_content_type="text/markdown", + long_description_content_type="text/markdown" )