diff options
author | Lars Wirzenius <liw@liw.fi> | 2019-07-20 16:52:01 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2019-08-03 21:06:50 +0300 |
commit | 8344a860d226d8a5172bcb2e9de5946717a950ca (patch) | |
tree | 83947c82747eb7404a575e40594e9afd059bfd08 /ick2/persistent.py | |
parent | 2cdb28a8350478a5d92607be8c95d5e5d43f4dfc (diff) | |
download | ick2-8344a860d226d8a5172bcb2e9de5946717a950ca.tar.gz |
Drop: use of old persistent state classes
Diffstat (limited to 'ick2/persistent.py')
-rw-r--r-- | ick2/persistent.py | 61 |
1 files changed, 1 insertions, 60 deletions
diff --git a/ick2/persistent.py b/ick2/persistent.py index e225b88..33903fe 100644 --- a/ick2/persistent.py +++ b/ick2/persistent.py @@ -25,66 +25,7 @@ import yaml import ick2 -class PersistentStateInterface: # pragma: no cover - - def get_resource_names(self, token, kind): - raise NotImplementedError() - - def has_resource(self, token, kind, name): - raise NotImplementedError() - - def get_resource(self, token, kind, name): - raise NotImplementedError() - - def get_resources(self, token, kind): - return [ - self.get_resource(token, kind, name) - for name in self.get_resource_names(token, kind) - ] - - def write_resource(self, token, kind, name, resource): - raise NotImplementedError() - - def update_resource(self, token, kind, name, resource): - raise NotImplementedError() - - def remove_resource(self, token, kind, name): - raise NotImplementedError() - - -class MemoryPersistentState(PersistentStateInterface): - - def __init__(self): - self._res = {} - - def get_resource_names(self, token, kind): - if kind not in self._res: - return [] - return list(self._res[kind].keys()) - - def has_resource(self, token, kind, name): - return kind in self._res and name in self._res[kind] - - def get_resource(self, token, kind, name): - if kind not in self._res or name not in self._res[kind]: - raise ick2.NotFound(kind=kind, name=name) - return self._res[kind][name] - - def write_resource(self, token, kind, name, resource): - if kind not in self._res: - self._res[kind] = {} - self._res[kind][name] = resource - - def update_resource(self, token, kind, name, resource): - self.write_resource(token, kind, name, resource) - - def remove_resource(self, token, kind, name): - if kind not in self._res or name not in self._res[kind]: - raise ick2.NotFound(kind=kind, name=name) - del self._res[kind][name] - - -class NotFound(Exception): +class NotFound(Exception): # pragma: no cover def __init__(self, kind, name): super().__init__( |