Exemplo n.º 1
0
def _mktree(tree):
    """Given a tree, return a list of (path, opts) tuples
    with opts applied hiearchically, i.e. opts specified at a node
    also get applied to subnodes (unless later overridden)"""
    tps = [tp for tp in treant.paths_preorder(tree)]

    # construct two parallel lists: paths, and opts of each path
    paths = [_path(tp) for tp in tps]
    opts = [_opts(tp) for tp in tps]

    return zip(paths, opts)
Exemplo n.º 2
0
def test_paths_preorder():
    nodes = ['/', ['opt', 'framed', 'mcv']]

    t = tree(nodes)
    root = get(t, ['/'])
    opt = get(t, ['/', 'opt'])
    framed = get(t, ['/', 'opt', 'framed'])
    mcv = get(t, ['/', 'opt', 'mcv'])

    paths = [p for p in paths_preorder(t)]

    eq_(paths,
        [[root],
         [root, opt],
         [root, opt, framed],
         [root, opt, mcv]])
Exemplo n.º 3
0
def paths(tree):
    # list of tpaths, i.e. list of (list of nodes)
    tps = [tp for tp in treant.paths_preorder(tree)]
    return [_path(tp) for tp in tps]