diff options
Diffstat (limited to 'src/hydrilla/proxy/state.py')
-rw-r--r-- | src/hydrilla/proxy/state.py | 63 |
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] |