From f2b91572b163099b29c940cf6fe5814a047fdc51 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 31 Aug 2022 16:15:58 +0200 Subject: [proxy] make information about mapping version being frozen available to UI code --- src/hydrilla/proxy/state.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/hydrilla/proxy/state.py') diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py index 69436c5..1246c92 100644 --- a/src/hydrilla/proxy/state.py +++ b/src/hydrilla/proxy/state.py @@ -52,15 +52,37 @@ from .simple_dependency_satisfying import ImpossibleSituation class EnabledStatus(Enum): """ - ENABLED - User wished to always apply given mapping when it matched. + ENABLED - User wished to always apply given mapping when it matches site's + URL. DISABLED - User wished to never apply given mapping. - NO_MARK - User has not configured given mapping and it won't be used. + NO_MARK - User has not configured given mapping. """ - ENABLED = 'E' - DISABLED = 'D' - NO_MARK = 'N' + ENABLED = 'E' + DISABLED = 'D' + NO_MARK = 'N' + + +class FrozenStatus(Enum): + """ + EXACT_VERSION - User wished to always use the same version of a mapping. + + REPOSITORY - User wished to always use a version of the mapping from the + same repository. + + NOT_FROZEN - User did not restrict updates of the mapping. + """ + EXACT_VERSION = 'E' + REPOSITORY = 'R' + NOT_FROZEN = 'N' + + @staticmethod + def make(letter: t.Optional[str]) -> t.Optional[FrozenStatus]: + if letter is None: + return None + + return FrozenStatus(letter) class InstalledStatus(Enum): @@ -201,6 +223,7 @@ class MappingDisplayInfo(item_infos.CorrespondsToMappingDCMixin): ref: 'MappingRef' identifier: str enabled: EnabledStatus + frozen: t.Optional[FrozenStatus] active_version: t.Optional['MappingVersionDisplayInfo'] @dc.dataclass(frozen=True) @@ -212,6 +235,7 @@ class MappingVersionDisplayInfo(item_infos.CorrespondsToMappingDCMixin): is_orphan: bool is_local: bool mapping_enabled: EnabledStatus + mapping_frozen: t.Optional[FrozenStatus] @dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc] class MappingRef(Ref, item_infos.CorrespondsToMappingDCMixin): -- cgit v1.2.3