diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-08-18 19:18:00 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-09-28 12:54:22 +0200 |
commit | e1344ae7017b28a54d7714895bd54c8431a20bc6 (patch) | |
tree | 66bfcb166a87afa10a0b45100231c102385baf08 /src/hydrilla/proxy/state.py | |
parent | 2579081df2a568192887d776a6965af323b7c4ee (diff) | |
download | haketilo-hydrilla-e1344ae7017b28a54d7714895bd54c8431a20bc6.tar.gz haketilo-hydrilla-e1344ae7017b28a54d7714895bd54c8431a20bc6.zip |
allow adding, removing and altering repositories
This commit also temporarily breaks package import from files :/
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: """....""" ... |