def _hash_name(self, name):
return hashutil.dir_name_hash(self._readkey, name)
+ def has_child(self, name):
+ d = self.get(name)
+ def _good(res):
+ return True
+ def _err(f):
+ f.trap(KeyError)
+ return False
+ d.addCallbacks(_good, _err)
+ return d
+
def get(self, name):
H_name = self._hash_name(name)
d = self._rref.callRemote("get", self._index, H_name)
"""I return a Deferred that fires with a dictionary mapping child
name to an IFileNode or IDirectoryNode."""
+ def has_child(name):
+ """I return a Deferred that fires with a boolean, True if there
+ exists a child of the given name, False if not."""
+
def get(name):
"""I return a Deferred that fires with a specific named child node,
either an IFileNode or an IDirectoryNode."""
# root/bar-ro/file4 = file2
# root/bar-ro/baz/
+ # test has_child
+ d.addCallback(lambda res: rootnode.has_child("bar"))
+ d.addCallback(self.failUnlessEqual, True)
+ d.addCallback(lambda res: rootnode.has_child("missing"))
+ d.addCallback(self.failUnlessEqual, False)
+
# test the manifest
d.addCallback(lambda res: self.rootnode.build_manifest())
def _check_manifest2(manifest):