fix: issues (1)

This commit is contained in:
2026-02-12 08:54:19 +01:00
parent 8ec92a685c
commit d316601e9a
27 changed files with 440 additions and 235 deletions

View File

@@ -1,6 +1,6 @@
from typing import Optional, Any, Union
from dataclasses import dataclass
from omegaconf import OmegaConf, DictConfig
from omegaconf import OmegaConf, DictConfig, ListConfig
import os
from pathlib import Path
@@ -140,7 +140,7 @@ class Config:
"""
_config: Optional[DictConfig] = None
_config: Optional[Union[DictConfig, ListConfig]] = None
config_exists: bool = True
def __init__(self, config_path: str):
@@ -183,22 +183,25 @@ class Config:
"""
Reloads the configuration from the file.
"""
self._config = OmegaConf.load(self.config_path)
if self.config_path is not None:
self._config = OmegaConf.load(self.config_path)
@property
def zotero(self):
if self._config is None:
raise RuntimeError("Configuration not loaded")
return Zotero(**self._config.zotero)
@property
def zotero_attr(self, name: str):
def get_zotero_attr(self, name: str):
return getattr(self.zotero, name)
@zotero_attr.setter
def zotero_attr(self, name: str, value: Any):
def set_zotero_attr(self, name: str, value: Any):
self.zotero._setattr(name, value)
@property
def database(self):
if self._config is None:
raise RuntimeError("Configuration not loaded")
return Database(**self._config.database)
@property
@@ -211,43 +214,57 @@ class Config:
@property
def openAI(self):
if self._config is None:
raise RuntimeError("Configuration not loaded")
return OpenAI(**self._config.openAI)
@property
def mail(self):
if self._config is None:
raise RuntimeError("Configuration not loaded")
return Mail(**self._config.mail)
def mail_attr(self, name: str):
return getattr(self.mail, name)
def set_mail_attr(self, name: str, value: Any):
OmegaConf.update(self._config, f"mail.{name}", value)
if self._config is not None:
OmegaConf.update(self._config, f"mail.{name}", value)
def set_database_attr(self, name: str, value: Any):
OmegaConf.update(self._config, f"database.{name}", value)
if self._config is not None:
OmegaConf.update(self._config, f"database.{name}", value)
def set_zotero_attr(self, name: str, value: Any):
OmegaConf.update(self._config, f"zotero.{name}", value)
if self._config is not None:
OmegaConf.update(self._config, f"zotero.{name}", value)
def set_openai_attr(self, name: str, value: Any):
OmegaConf.update(self._config, f"openAI.{name}", value)
if self._config is not None:
OmegaConf.update(self._config, f"openAI.{name}", value)
def set_icon_attr(self, name: str, value: Any):
OmegaConf.update(self._config, f"icons.{name}", value)
if self._config is not None:
OmegaConf.update(self._config, f"icons.{name}", value)
@property
def save_path(self):
if self._config is None:
raise RuntimeError("Configuration not loaded")
return self._config.save_path
@save_path.setter
def save_path(self, value: str):
self._config.save_path = value
if self._config is not None:
self._config.save_path = value
def load_config(self, path, filename):
return OmegaConf.load(os.path.join(path, filename))
@property
def icons(self):
if self._config is None:
raise RuntimeError("Configuration not loaded")
icons = Icons()
icons.assign("path", self._config.icon_path)
icons.assign("colors", self._config.colors)