This commit is contained in:
2025-11-02 18:34:33 +03:00
parent 6f90712a17
commit f0a18e89c8
9 changed files with 184 additions and 355 deletions
+3
View File
@@ -0,0 +1,3 @@
__all__ = ["DataBridge"]
from .entity import DataBridge as DataBridge
+23
View File
@@ -0,0 +1,23 @@
__all__ = ["DataBridge"]
from typing import Any
class DataBridge:
def __init__(self, initial_data: dict[str, Any] | None = None) -> None:
self._data: dict[str, Any] = initial_data if initial_data else {}
def update(self, data: dict[str, Any]) -> None:
self._data.update(data)
def get_all(self) -> dict[str, Any]:
return self._data
def clear_all(self) -> None:
self._data.clear()
def get_by_key(self, key: str) -> Any:
return self._data.get(key)
def delete_by_key(self, key: str) -> None:
self._data.pop(key)
+5
View File
@@ -4,6 +4,7 @@ __all__ = [
from dishka import Provider, Scope, provide
from argenta.data_bridge import DataBridge
from argenta.orchestrator.argparser import ArgParser
from argenta.orchestrator.argparser.entity import ArgSpace
@@ -16,3 +17,7 @@ class SystemProvider(Provider):
@provide(scope=Scope.APP)
def get_argspace(self) -> ArgSpace:
return self._arg_parser.parsed_argspace
@provide(scope=Scope.APP)
def get_data_bridge(self) -> DataBridge:
return DataBridge()
+1 -22
View File
@@ -1,5 +1,4 @@
__all__ = ["Response"]
from typing import Any
from dishka import Container
@@ -9,27 +8,7 @@ from argenta.response.status import ResponseStatus
EMPTY_INPUT_FLAGS: InputFlags = InputFlags()
class DataBridge:
_data: dict[str, Any] = {}
@classmethod
def update_data(cls, data: dict[str, Any]) -> None:
cls._data.update(data)
@classmethod
def get_data(cls) -> dict[str, Any]:
return cls._data
@classmethod
def clear_data(cls) -> None:
cls._data.clear()
@classmethod
def delete_from_data(cls, key: str) -> None:
cls._data.pop(key)
class Response(DataBridge):
class Response:
_dishka_container: Container
def __init__(