diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-08-17 13:50:34 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-09-28 12:54:13 +0200 |
commit | d54a95e0f9c689f2bbaaea90a3a16a855a408823 (patch) | |
tree | 2fcd758c6eaa7bc65a9744969a506c4ed24e0365 /src/hydrilla/proxy/state.py | |
parent | 2c98d04e4d4a344dc04a481b039a235678f7848e (diff) | |
download | haketilo-hydrilla-d54a95e0f9c689f2bbaaea90a3a16a855a408823.tar.gz haketilo-hydrilla-d54a95e0f9c689f2bbaaea90a3a16a855a408823.zip |
allow loading packages from zip files through web UI and listing installed mappings
Diffstat (limited to 'src/hydrilla/proxy/state.py')
-rw-r--r-- | src/hydrilla/proxy/state.py | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py index f511056..14d38b6 100644 --- a/src/hydrilla/proxy/state.py +++ b/src/hydrilla/proxy/state.py @@ -44,6 +44,7 @@ from immutables import Map from ..versions import VerTuple from ..url_patterns import ParsedPattern +from .. import item_infos class EnabledStatus(Enum): @@ -68,6 +69,14 @@ class Ref: id: str +RefType = t.TypeVar('RefType', bound=Ref) + +class Store(ABC, t.Generic[RefType]): + @abstractmethod + def get(self, id) -> RefType: + ... + + # mypy needs to be corrected: # https://stackoverflow.com/questions/70999513/conflict-between-mix-ins-for-abstract-dataclasses/70999704#70999704 @dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc] @@ -114,15 +123,35 @@ class MappingRef(Ref): """....""" ... +class MappingStore(Store[MappingRef]): + pass + @dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc] class MappingVersionRef(Ref): """....""" @abstractmethod - def enable(self, state: 'HaketiloState') -> None: + def update_status(self, new_status: EnabledStatus) -> None: """....""" ... + @abstractmethod + def get_display_info(self) -> MappingDisplayInfo: + ... + +@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]: + ... + + @dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc] class ResourceRef(Ref): """....""" @@ -167,23 +196,23 @@ class FileData: class PayloadRef(Ref): """....""" @abstractmethod - def get_data(self, state: 'HaketiloState') -> PayloadData: + def get_data(self) -> PayloadData: """....""" ... @abstractmethod - def get_mapping(self, state: 'HaketiloState') -> MappingVersionRef: + def get_mapping(self) -> MappingVersionRef: """....""" ... @abstractmethod - def get_script_paths(self, state: 'HaketiloState') \ + def get_script_paths(self) \ -> t.Iterable[t.Sequence[str]]: """....""" ... @abstractmethod - def get_file_data(self, state: 'HaketiloState', path: t.Sequence[str]) \ + def get_file_data(self, path: t.Sequence[str]) \ -> t.Optional[FileData]: """....""" ... @@ -220,6 +249,10 @@ class MissingItemError(ValueError): class HaketiloState(ABC): """....""" @abstractmethod + def import_packages(self, malcontent_path: Path) -> None: + ... + + @abstractmethod def get_repo(self, repo_id: str) -> RepoRef: """....""" ... @@ -230,13 +263,12 @@ class HaketiloState(ABC): ... @abstractmethod - def get_mapping(self, mapping_id: str) -> MappingRef: + def mapping_store(self) -> MappingStore: """....""" ... @abstractmethod - def get_mapping_version(self, mapping_version_id: str) \ - -> MappingVersionRef: + def mapping_version_store(self) -> MappingVersionStore: """....""" ... |