diff options
Diffstat (limited to 'src/hydrilla/proxy/state.py')
-rw-r--r-- | src/hydrilla/proxy/state.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py index c3712f2..6414ae8 100644 --- a/src/hydrilla/proxy/state.py +++ b/src/hydrilla/proxy/state.py @@ -43,6 +43,7 @@ from datetime import datetime from immutables import Map +from ..exceptions import HaketiloException from ..versions import VerTuple from ..url_patterns import ParsedPattern from .. import item_infos @@ -81,6 +82,15 @@ class Store(ABC, t.Generic[RefType]): ... +class RepoNameInvalid(HaketiloException): + pass + +class RepoNameTaken(HaketiloException): + pass + +class RepoUrlInvalid(HaketiloException): + pass + # 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] @@ -97,7 +107,7 @@ class RepoRef(Ref): *, name: t.Optional[str] = None, url: t.Optional[str] = None - ) -> 'RepoRef': + ) -> None: """....""" ... @@ -112,13 +122,14 @@ class RepoRef(Ref): @dc.dataclass(frozen=True) class RepoDisplayInfo: - ref: RepoRef - name: str - url: t.Optional[str] - deleted: t.Optional[bool] - last_refreshed: t.Optional[datetime] - resource_count: int - mapping_count: int + ref: RepoRef + is_local_semirepo: bool + name: str + url: str + deleted: bool + last_refreshed: t.Optional[datetime] + resource_count: int + mapping_count: int class RepoStore(Store[RepoRef]): @abstractmethod @@ -126,6 +137,10 @@ class RepoStore(Store[RepoRef]): t.Iterable[RepoDisplayInfo]: ... + @abstractmethod + def add(self, name: str, url: str) -> RepoRef: + ... + @dc.dataclass(frozen=True, unsafe_hash=True) # type: ignore[misc] class RepoIterationRef(Ref): @@ -312,12 +327,6 @@ class HaketiloState(ABC): ... @abstractmethod - def add_repo(self, name: t.Optional[str], url: t.Optional[str]) \ - -> RepoRef: - """....""" - ... - - @abstractmethod def get_settings(self) -> HaketiloGlobalSettings: """....""" ... |