Пример #1
0
 def __getitem__(self, key):
     with _lock:
         self.__check_closed()
         key = _checkstr(key)
         drec = lib.pygdbm_fetch(self.__ll_dbm, key, len(key))
         if not drec.dptr:
             raise KeyError(key)
         res = str(ffi.buffer(drec.dptr, drec.dsize))
         lib.free(drec.dptr)
         return res
Пример #2
0
 def get(self, key, default=None):
     with _lock:
         self.__check_closed()
         key = _checkstr(key)
         drec = lib.pygdbm_fetch(self.__ll_dbm, key, len(key))
         if not drec.dptr:
             return default
         res = bytes(ffi.buffer(drec.dptr, drec.dsize))
         lib.free(drec.dptr)
         return res
Пример #3
0
 def __getitem__(self, key):
     with _lock:
         self.__check_closed()
         key = _checkstr(key)
         drec = lib.pygdbm_fetch(self.__ll_dbm, key, len(key))
         if not drec.dptr:
             raise KeyError(key)
         res = str(ffi.buffer(drec.dptr, drec.dsize))
         lib.free(drec.dptr)
         return res