예제 #1
0
파일: kyoto.py 프로젝트: coleifer/kvkit
 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
예제 #2
0
파일: rocks.py 프로젝트: adamchainz/kvkit
 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
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
 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
예제 #6
0
파일: leveldb.py 프로젝트: coleifer/kvkit
 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