sh_cpl/src/sh_edraft/configuration/configuration.py

26 lines
823 B
Python
Raw Normal View History

2020-11-25 21:41:45 +01:00
from collections import Callable
2020-11-26 10:45:02 +01:00
from sh_edraft.configuration.base.configuration_model_base import ConfigurationModelBase
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
2020-11-25 21:41:45 +01:00
class Configuration(ConfigurationBase):
def __init__(self):
super().__init__()
2020-11-26 11:20:21 +01:00
self._config: dict[type, object] = {}
2020-11-25 21:41:45 +01:00
def create(self): pass
def add_config_by_type(self, key_type: type, value: object):
self._config[key_type] = value
def get_config_by_type(self, search_type: type) -> Callable[ConfigurationModelBase]:
if search_type not in self._config:
raise Exception(f'Config model by type {search_type} not found')
for config_model in self._config:
if config_model == search_type:
return self._config[config_model]