def test_iter_path(): full_path = "/foo/bar/baz" expected_paths = {0: '/', 1: '/foo', 2: '/foo/bar', 3: '/foo/bar/baz'} for i, path in enumerate(iter_paths(full_path)): assert expected_paths[i] == path
def walk(self): """ Build nodes dict from already-populated lookup table. """ for path, info in self.lookup_table.iteritems(): parent = None ancestors = [] level = 0 for parent_path in iter_paths(path): if not self.nodes.has_key(parent_path): node = Node(parent_path, parent, []) node.level = level self.nodes[parent_path] = node if parent: parent.children.append(node) if not self.root and parent_path == '/': self.root = node parent = self.nodes[parent_path] ancestors.append(parent) level += 1 assert parent.location == path parent.ancestors = ancestors parent.docs = info['docs'] if info.has_key('index-page'): parent.index_page = info['index-page']
def walk(self): """ Build nodes dict from already-populated lookup table. """ for path, info in self.lookup_table.items(): parent = None ancestors = [] level = 0 for parent_path in iter_paths(path): if not parent_path in self.nodes: node = Node(parent_path, parent, []) node.level = level self.nodes[parent_path] = node if parent: parent.children.append(node) if not self.root and parent_path == '/': self.root = node parent = self.nodes[parent_path] ancestors.append(parent) level += 1 assert parent.location == path parent.ancestors = ancestors parent.docs = info['docs'] if 'index-page' in info: parent.index_page = info['index-page']
def test_iter_path(): full_path = "/foo/bar/baz" expected_paths = {0: "/", 1: "/foo", 2: "/foo/bar", 3: "/foo/bar/baz"} for i, path in enumerate(iter_paths(full_path)): assert expected_paths[i] == path
def test_iter_path(): full_path = "/foo/bar/baz" expected_paths = { 0 : '/', 1 : '/foo', 2 : '/foo/bar', 3 : '/foo/bar/baz' } for i, path in enumerate(iter_paths(full_path)): assert expected_paths[i] == path