aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/state.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-08-23 09:26:16 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-28 12:54:52 +0200
commit5fefb11ffd50dcda826cd5a256c8b3f650221050 (patch)
treed98721a1b054b894e282668aea79157788903e73 /src/hydrilla/proxy/state.py
parentc100476b0a34f5098efc96bf2487f09b66b4a6c4 (diff)
downloadhaketilo-hydrilla-5fefb11ffd50dcda826cd5a256c8b3f650221050.tar.gz
haketilo-hydrilla-5fefb11ffd50dcda826cd5a256c8b3f650221050.zip
introduce package installation state enum
Diffstat (limited to 'src/hydrilla/proxy/state.py')
-rw-r--r--src/hydrilla/proxy/state.py63
1 files changed, 44 insertions, 19 deletions
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py
index d975d2f..0c6dff3 100644
--- a/src/hydrilla/proxy/state.py
+++ b/src/hydrilla/proxy/state.py
@@ -65,6 +65,24 @@ class EnabledStatus(Enum):
AUTO_ENABLED = 'A'
NO_MARK = 'N'
+
+class InstalledStatus(Enum):
+ """
+ INSTALLED - Mapping's all files are present and mapping data is not going to
+ be automatically removed.
+
+ NOT_INSTALLED - Some of the mapping's files might be absent. Mapping can be
+ automatically removed if it is orphaned.
+
+ FAILED_TO_INSTALL - Same as "NOT_INSTALLED" but we additionally know that
+ the last automatic attempt to install mapping's files from repository
+ was unsuccessful.
+ """
+ INSTALLED = 'I'
+ NOT_INSTALLED = 'N'
+ FAILED_TO_INSTALL = 'F'
+
+
@dc.dataclass(frozen=True, unsafe_hash=True)
class Ref:
"""...."""
@@ -145,7 +163,7 @@ class RepoDisplayInfo:
class RepoStore(Store[RepoRef]):
@abstractmethod
def get_display_infos(self, include_deleted: bool = False) -> \
- t.Iterable[RepoDisplayInfo]:
+ t.Sequence[RepoDisplayInfo]:
...
@abstractmethod
@@ -159,21 +177,37 @@ class RepoIterationRef(Ref):
pass
+@dc.dataclass(frozen=True)
+class MappingDisplayInfo:
+ ref: 'MappingRef'
+ identifier: str
+ enabled: EnabledStatus
+ active_version_ref: t.Optional['MappingVersionRef']
+ active_version_info: t.Optional[item_infos.MappingInfo]
+
+@dc.dataclass(frozen=True)
+class MappingVersionDisplayInfo:
+ ref: 'MappingVersionRef'
+ info: item_infos.MappingInfo
+ installed: InstalledStatus
+ is_active: bool
+ is_orphan: bool
+ is_local: bool
+ mapping_enabled: EnabledStatus
+
@dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc]
class MappingRef(Ref):
"""...."""
@abstractmethod
- def disable(self, state: 'HaketiloState') -> None:
- """...."""
+ def get_version_display_infos(self) \
+ -> t.Sequence[MappingVersionDisplayInfo]:
...
- @abstractmethod
- def forget_enabled(self, state: 'HaketiloState') -> None:
- """...."""
- ...
class MappingStore(Store[MappingRef]):
- pass
+ @abstractmethod
+ def get_display_infos(self) -> t.Sequence[MappingDisplayInfo]:
+ ...
@dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc]
@@ -185,20 +219,11 @@ class MappingVersionRef(Ref):
...
@abstractmethod
- def get_display_info(self) -> MappingDisplayInfo:
+ def get_display_info(self) -> MappingVersionDisplayInfo:
...
-@dc.dataclass(frozen=True)
-class MappingDisplayInfo:
- ref: MappingVersionRef
- info: item_infos.MappingInfo
- enabled: EnabledStatus
- is_orphan: bool
-
class MappingVersionStore(Store[MappingVersionRef]):
- @abstractmethod
- def get_display_infos(self) -> t.Iterable[MappingDisplayInfo]:
- ...
+ pass
@dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc]