def __getitem__(self, key): if isinstance(key, (list, tuple)): return self.db.get_bulk(key, True) elif isinstance(key, slice): start, stop, reverse = clean_key_slice(key) if reverse: return self.get_slice_rev(start, stop) else: return self.get_slice(start, stop) else: value = self.db.get(key) if value is None: raise KeyError(key) return value
def __getitem__(self, key): if isinstance(key, slice): start, stop, reverse = clean_key_slice(key) if reverse: return self.get_slice_rev(start, stop) else: return self.get_slice(start, stop) elif isinstance(key, (list, tuple)): return self.db.multi_get(key) else: res = self.db.get(key) if res is None: raise KeyError(key) return res
def __getitem__(self, key): if isinstance(key, slice): start, stop, reverse = clean_key_slice(key) if reverse: # LevelDB uses slightly different meaning for start/stop when # reverse than kyotocabinet. start, stop = stop, start return self.db.iterator(start=start, stop=stop, include_start=True, include_stop=True, reverse=reverse) elif isinstance(key, (list, tuple)): pass else: res = self.db.get(key) if res is None: raise KeyError(key) return res
def __getitem__(self, key): if isinstance(key, slice): start, stop, reverse = clean_key_slice(key) if reverse: # LevelDB uses slightly different meaning for start/stop when # reverse than kyotocabinet. start, stop = stop, start return self.db.iterator( start=start, stop=stop, include_start=True, include_stop=True, reverse=reverse) elif isinstance(key, (list, tuple)): pass else: res = self.db.get(key) if res is None: raise KeyError(key) return res