diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-08-31 16:15:58 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-09-28 12:54:55 +0200 |
commit | f2b91572b163099b29c940cf6fe5814a047fdc51 (patch) | |
tree | a09aff977f67c6ea15edc5b3a1e6180e97e0699f /src/hydrilla/proxy/state.py | |
parent | 55f8688c851d4f5f32a35fd804f31ad2f355be37 (diff) | |
download | haketilo-hydrilla-f2b91572b163099b29c940cf6fe5814a047fdc51.tar.gz haketilo-hydrilla-f2b91572b163099b29c940cf6fe5814a047fdc51.zip |
[proxy] make information about mapping version being frozen available to UI code
Diffstat (limited to 'src/hydrilla/proxy/state.py')
-rw-r--r-- | src/hydrilla/proxy/state.py | 34 |
1 files changed, 29 insertions, 5 deletions
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): |