From 1f7d6538c47ba79ad6645fec892ed4b0eb022aa8 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Thu, 11 Nov 2010 22:49:58 -0500 Subject: [PATCH] Tree lookup Lookup will follow a path and return whatever node it is pointing to. --- libsaria/trees.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libsaria/trees.py b/libsaria/trees.py index f4349888..24337bd9 100644 --- a/libsaria/trees.py +++ b/libsaria/trees.py @@ -47,6 +47,13 @@ class Tree(dict): if len(path) > 1: child.insert(path[1:]) + def lookup(self, path): + print self.keys(), path + child = self[path[0]] + if len(path) > 1: + return child.lookup(path[1:]) + return child + class DLTree(Tree): def __init__(self):