Beispiel #1
0
 def __setitem__(self, key, value):
     assert isinstance(key, bytes)
     value = num2str(value)
     treekey = key[:6]
     tree = self._data.get(treekey)
     if tree is None:
         tree = fsBucket()
         self._data[treekey] = tree
     tree[key[6:]] = value
Beispiel #2
0
 def load(class_, fname):
     with open(fname, 'rb') as f:
         unpickler = Unpickler(f)
         pos = unpickler.load()
         if not isinstance(pos, INT_TYPES):
             # NB: this might contain OIDs that got unpickled
             # into Unicode strings on Python 3; hope the caller
             # will pipe the result to fsIndex().update() to normalize
             # the keys
             return pos                  # Old format
         index = class_()
         data = index._data
         while 1:
             v = unpickler.load()
             if not v:
                 break
             k, v = v
             data[ensure_bytes(k)] = fsBucket().fromString(ensure_bytes(v))
         return dict(pos=pos, index=index)
Beispiel #3
0
 def _setstate_1(self, state):
     self._data = OOBTree([
         (ensure_bytes(k), fsBucket().fromString(ensure_bytes(v)))
         for (k, v) in state['_data']
         ])