mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-23 01:08:53 +00:00
add IDirectoryNode.get_child_at_path
This commit is contained in:
@ -362,6 +362,20 @@ class ImmutableDirectoryNode:
|
||||
wk, we, rk, index = hashutil.generate_dirnode_keys_from_readkey(rk)
|
||||
return "DIR-REFRESH:%s" % idlib.b2a(index)
|
||||
|
||||
def get_child_at_path(self, path):
|
||||
if not path:
|
||||
return self
|
||||
if isinstance(path, (str, unicode)):
|
||||
path = path.split("/")
|
||||
childname = path[0]
|
||||
remaining_path = path[1:]
|
||||
d = self.get(childname)
|
||||
if remaining_path:
|
||||
def _got(node):
|
||||
return node.get_child_at_path(remaining_path)
|
||||
d.addCallback(_got)
|
||||
return d
|
||||
|
||||
class MutableDirectoryNode(ImmutableDirectoryNode):
|
||||
implements(IDirectoryNode)
|
||||
|
||||
|
Reference in New Issue
Block a user