Example #1
0
 def test_parse_animals(self):
     expr1 = """
         animals ( 
             canines ( domestic(dogs), 
                 wild ( wolves, coyotes ) ),
             felines ( domestic(house_cats), 
                 wild ( lions, tigers, cheetahs, leopards )))
     """
     tree = Graph()
     parser = ParseSimpleExpr(StringIO(expr1), tree)
     parser.run()
     self.assertEqual(str(is_tree(tree)), 'animals')
     self.assertEqual(tree.num_vertices(), 15)
Example #2
0
 def test_parse_animals(self):
     expr1 = """
         animals ( 
             canines ( domestic(dogs), 
                 wild ( wolves, coyotes ) ),
             felines ( domestic(house_cats), 
                 wild ( lions, tigers, cheetahs, leopards )))
     """
     tree = Graph()
     parser = ParseSimpleExpr(StringIO(expr1), tree)
     parser.run()
     self.assertEqual(str(is_tree(tree)), 'animals')
     self.assertEqual(tree.num_vertices(), 15)
Example #3
0
    def __init__(self, tree, **kw_args):
        super().__init__(initial='write', **kw_args)

        if type(tree) is GraphWrapper:
            self.tree = tree
        else:
            self.tree = GraphWrapper(tree)

        self.root = is_tree(self.tree)
        if self.root == None:
            raise TypeError("Graph is not a tree.")

        self.indent = 0

        self.active_frame.node = self.root
        self.active_frame.children = []
Example #4
0
    def __init__(self, tree, **kw_args):
        super().__init__(initial='write', **kw_args)

        if type(tree) is GraphWrapper:
            self.tree = tree
        else:
            self.tree = GraphWrapper(tree)

        self.root = is_tree(self.tree)
        if self.root == None:
            raise TypeError("Graph is not a tree.")

        self.indent = 0

        self.active_frame.node = self.root
        self.active_frame.children = []