From 043ec601efb7cd5c68c40b8a0e30357e8c631063 Mon Sep 17 00:00:00 2001 From: JarbasAI <33701864+JarbasAl@users.noreply.github.com> Date: Sun, 29 Dec 2024 01:56:14 +0000 Subject: [PATCH] fix: move to dataclass + requirements.txt (#5) --- hivemind_sqlite_database/__init__.py | 9 +++++++-- requirements.txt | 1 + setup.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 requirements.txt diff --git a/hivemind_sqlite_database/__init__.py b/hivemind_sqlite_database/__init__.py index 8dbb4be..8ac775d 100644 --- a/hivemind_sqlite_database/__init__.py +++ b/hivemind_sqlite_database/__init__.py @@ -8,15 +8,20 @@ from hivemind_plugin_manager.database import Client, AbstractDB +from dataclasses import dataclass + +@dataclass class SQLiteDB(AbstractDB): """Database implementation using SQLite.""" + name: str = "clients" + subfolder: str = "hivemind-core" - def __init__(self, name="clients", subfolder="hivemind-core"): + def __post_init__(self): """ Initialize the SQLiteDB connection. """ - db_path = os.path.join(xdg_data_home(), subfolder, name + ".db") + db_path = os.path.join(xdg_data_home(), self.subfolder, self.name + ".db") LOG.debug(f"sqlite database path: {db_path}") os.makedirs(os.path.dirname(db_path), exist_ok=True) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fb5914f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +hivemind-plugin-manager>=0.1.0,<1.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 8bf0b04..49a8b45 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ def required(requirements_file): url='https://github.com/JarbasHiveMind/hivemind-sqlite-database', license='Apache-2.0', author='jarbasAi', - # install_requires=required("requirements.txt"), + install_requires=required("requirements.txt"), entry_points={'hivemind.database': PLUGIN_ENTRY_POINT}, author_email='jarbasai@mailfence.com', description='sqlite database plugin for hivemind-core'