WIP: dev into master #184
@@ -115,18 +115,7 @@ class Configuration:
|
|||||||
if sub.__name__ != key and sub.__name__.replace("Settings", "") != key:
|
if sub.__name__ != key and sub.__name__.replace("Settings", "") != key:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
configuration = sub()
|
configuration = JSONProcessor.process(sub, value)
|
||||||
from_dict = getattr(configuration, "from_dict", None)
|
|
||||||
|
|
||||||
if from_dict is not None and not hasattr(from_dict, "is_base_func"):
|
|
||||||
Console.set_foreground_color(ForegroundColorEnum.yellow)
|
|
||||||
Console.write_line(
|
|
||||||
f"{sub.__name__}.from_dict is deprecated. Instead, set attributes as typed arguments in __init__. They can be None by default!"
|
|
||||||
)
|
|
||||||
Console.color_reset()
|
|
||||||
configuration.from_dict(value)
|
|
||||||
else:
|
|
||||||
configuration = JSONProcessor.process(sub, value)
|
|
||||||
|
|
||||||
cls.set(sub, configuration)
|
cls.set(sub, configuration)
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,5 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC
|
||||||
|
|
||||||
|
|
||||||
def base_func(method):
|
|
||||||
method.is_base_func = True
|
|
||||||
return method
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationModelABC(ABC):
|
class ConfigurationModelABC(ABC):
|
||||||
@abstractmethod
|
pass
|
||||||
def __init__(self):
|
|
||||||
r"""ABC for settings representation"""
|
|
||||||
|
|
||||||
@base_func
|
|
||||||
def from_dict(self, settings: dict):
|
|
||||||
r"""DEPRECATED: Set attributes as typed arguments in __init__ instead. See https://docs.sh-edraft.de/cpl/deprecated.html#ConfigurationModelABC-from_dict-method for further information
|
|
||||||
Converts attributes to dict
|
|
||||||
|
|
||||||
Parameter:
|
|
||||||
settings: :class:`dict`
|
|
||||||
"""
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl.application import ApplicationABC
|
from cpl.application import ApplicationABC
|
||||||
from cpl.core.configuration import Configuration
|
|
||||||
from cpl.core.console import Console
|
from cpl.core.console import Console
|
||||||
from cpl.core.environment import Environment
|
from cpl.core.environment import Environment
|
||||||
from cpl.dependency import ServiceProviderABC
|
|
||||||
from cpl.core.log import LoggerABC
|
from cpl.core.log import LoggerABC
|
||||||
from model.user_repo_abc import UserRepoABC
|
from cpl.dependency import ServiceProviderABC
|
||||||
from model.user_repo import UserRepo
|
from model.user_repo import UserRepo
|
||||||
|
from model.user_repo_abc import UserRepoABC
|
||||||
|
|
||||||
|
|
||||||
class Application(ApplicationABC):
|
class Application(ApplicationABC):
|
||||||
|
|||||||
Reference in New Issue
Block a user