def get_config_tree(config_str):
    config_tokens = config_str.split()

    if "nil" not in config_tokens:
        config_str += " " + " ".join(["nil"] * len(config_tokens))

    tree = Tree()
    tree.parse(config_str, int)
    # convert from 1-indexed to zero-indexed
    tree = tree.dfs(lambda x: x - 1)

    return tree
def get_config_tree(config_str):
    config_tokens = config_str.split()

    if 'nil' not in config_tokens:
        config_str += ' ' + ' '.join(['nil'] * len(config_tokens))

    tree = Tree()
    tree.parse(config_str, int)
    # convert from 1-indexed to zero-indexed
    tree = tree.dfs(lambda x: x - 1)

    return tree
예제 #3
0
#!/usr/bin/env python

from tree_ import Tree
from sys import argv

assert (len(argv) == 2)

t = Tree()

# method 2
t.parse(argv[1], str, 2)
print t.to_string()

# method 1
t.parse(argv[1], str)
print t.to_string()
예제 #4
0
#!/usr/bin/env python

from tree_ import Tree
from sys import argv

assert(len(argv) == 2)

t = Tree()

# method 2
t.parse(argv[1], str, 2)
print t.to_string()

# method 1
t.parse(argv[1], str)
print t.to_string()