ui change, bugfix
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
from typing import Optional
|
||||
|
||||
import omegaconf
|
||||
|
||||
class Config:
|
||||
_config: Optional[omegaconf.DictConfig] = None
|
||||
|
||||
def __init__(self, config_path: str):
|
||||
"""
|
||||
Loads the configuration file and stores it for future access.
|
||||
|
||||
Args:
|
||||
config_path (str): Path to the YAML configuration file.
|
||||
"""
|
||||
self._config = omegaconf.OmegaConf.load(config_path)
|
||||
|
||||
@property
|
||||
def institution_name(self)->str:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.institution_name
|
||||
@property
|
||||
def loan_duration(self)->int:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.default_loan_duration
|
||||
@property
|
||||
def delete_inactive_user_duration(self)->int:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.inactive_user_deletion
|
||||
@property
|
||||
def catalogue(self)->bool:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.catalogue
|
||||
@property
|
||||
def database(self)->omegaconf.DictConfig:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.database
|
||||
|
||||
@property
|
||||
def report(self)->omegaconf.DictConfig:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.report
|
||||
@property
|
||||
def debug(self)->bool:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.debug
|
||||
@property
|
||||
def log_debug(self)->bool:
|
||||
if self._config is None:
|
||||
raise RuntimeError("Configuration not loaded")
|
||||
return self._config.log_debug
|
||||
|
||||
|
||||
def updateValue(self, key: str, value: str):
|
||||
self._config[key] = value
|
||||
omegaconf.OmegaConf.save(self._config, "config/settings.yaml")
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cfg = Config("config/settings.yaml")
|
||||
print(cfg.database.path)
|
||||
|
||||
#cfg.updateValue("database.path", "Test")
|
||||
Reference in New Issue
Block a user