for (H_key, E_key, E_write, E_read) in data[1]:
if H_key == key:
return (E_write, E_read)
- raise IndexError("unable to find key %s" % idlib.b2a(key))
+ raise KeyError("unable to find key %s" % idlib.b2a(key))
remote_get = get
def list(self, index):
del data[1][i]
self._write_to_file(index, data)
return
- raise IndexError("unable to find key %s" % idlib.b2a(key))
+ raise KeyError("unable to find key %s" % idlib.b2a(key))
remote_delete = delete
def set(self, index, write_enabler, key, name, write, read):
H_name = self._hash_name(name)
d = self._rref.callRemote("get", self._index, H_name)
def _check_index_error(f):
- f.trap(IndexError)
- raise IndexError("get(index=%s): unable to find child named '%s'"
- % (idlib.b2a(self._index), name))
+ f.trap(KeyError)
+ raise KeyError("get(index=%s): unable to find child named '%s'"
+ % (idlib.b2a(self._index), name))
d.addErrback(_check_index_error)
d.addCallback(lambda (E_write, E_read):
self._decrypt_child(E_write, E_read))
("write1", "read1"))
self.failUnlessEqual(vds.get(index, "key2"),
("", "read2"))
- self.failUnlessRaises(IndexError,
+ self.failUnlessRaises(KeyError,
vds.get, index, "key3")
self.failUnlessEqual(sorted(vds.list(index)),
[ ("name1", "write1", "read1"),
("name2", "", "read2"),
])
- self.failUnlessRaises(IndexError,
+ self.failUnlessRaises(KeyError,
vds.delete,
index, we, "key3")
self.failUnlessEqual(sorted(vds.list(index)),
[ ("name2", "", "read2"),
])
- self.failUnlessRaises(IndexError,
+ self.failUnlessRaises(KeyError,
vds.get, index, "key1")
self.failUnlessEqual(vds.get(index, "key2"),
("", "read2"))
d.addCallback(lambda res: rootnode.get("missing"))
# this should raise an exception
- d.addBoth(self.shouldFail, IndexError, "get('missing')",
+ d.addBoth(self.shouldFail, KeyError, "get('missing')",
"unable to find child named 'missing'")
d.addCallback(lambda res: rootnode.create_empty_directory("bar"))