45 lines
994 B
Python
45 lines
994 B
Python
import toml
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class DatabaseConfig:
|
|
_host: str
|
|
|
|
def __init__(self, config: dict):
|
|
self._host = config["HOST"]
|
|
|
|
@property
|
|
def host(self) -> str:
|
|
return self._host
|
|
|
|
|
|
@dataclass
|
|
class KeePassConfig:
|
|
_path: str
|
|
|
|
def __init__(self, config: dict):
|
|
self._path = config["PATH"]
|
|
|
|
@property
|
|
def path(self) -> str:
|
|
return self._path
|
|
|
|
@dataclass
|
|
class Config:
|
|
_config: dict
|
|
_kee_pass_config: KeePassConfig
|
|
_database_config: DatabaseConfig
|
|
def __init__(self):
|
|
with open('config.toml', 'r') as f:
|
|
self._config = toml.load(f)
|
|
self._kee_pass_config = KeePassConfig(self._config['keepass'])
|
|
self._database_config = DatabaseConfig(self._config['database'])
|
|
|
|
@property
|
|
def kee_pass(self) -> KeePassConfig:
|
|
return self._kee_pass_config
|
|
|
|
@property
|
|
def database(self) -> DatabaseConfig:
|
|
return self._database_config |