def get(self, **kwargs):
return cursor(self.index().get(**kwargs), self.store)
+ def get1(self, *, check=False, default=KeyError, **kwargs):
+ with self.get(**kwargs) as cursor:
+ try:
+ k, v = next(cursor)
+ except StopIteration:
+ if default is not KeyError:
+ return default
+ raise KeyError("no matches in " + self.name, kwargs)
+ if check:
+ try:
+ next(cursor)
+ except StopIteration:
+ pass
+ else:
+ raise ValueError("unexpected multiple matchies in " + self.name, kwargs)
+ return v
+
+ def list(self, **kwargs):
+ with self.get(**kwargs) as cursor:
+ return [v for k, v in cursor]
+
class descbase(base):
def __init__(self, store, indextype, name, datatype, default):
super().__init__(store, indextype, name, datatype)