Beispiel #1
0
 def get_children_by_meta(meta, nodes_ids):
     root_node = Node('root', (None, None))
     encode_list_of_pathes_into_node(root_node, list_of_pathes, description)
     node_ids = []
     meta_filter = Meta(meta[0], meta[1])
     output_node = root_node.get_children_by_meta(meta_filter, node_ids)
     return node_ids
Beispiel #2
0
 def get_parent_by_meta(meta_filter, id):
     meta_filter = Meta(meta_filter[0], meta_filter[1])
     root_node = Node('root', (None, None))
     encode_list_of_pathes_into_node(root_node, list_of_pathes, description)
     default_node = LIST_OF_NODES[id]
     output_node = default_node.get_parent_by_meta(meta_filter)
     return output_node
Beispiel #3
0
 def get_path(id):
     root_node = Node('root', (None, None))
     path = []
     metas = []
     encode_list_of_pathes_into_node(root_node, list_of_pathes, description)
     default_node = LIST_OF_NODES[id]
     default_node.get_path(path, metas)
     return path
Beispiel #4
0
 def add_child(name):
     depth = len(list_of_pathes) - 2
     tree = list_of_pathes[:-1]
     root_node = Node('root', (None, None))
     encode_list_of_pathes_into_node(root_node, list_of_pathes[:-1],
                                     description)
     last_node = LIST_OF_NODES[depth]
     last_node.add_child(name,
                         Meta(description[name][0], description[name][1]))
     last_node.children[-1].id = depth + 1
     return root_node
Beispiel #5
0
def test_preparation(description, list_of_pathes):
    '''Test for encoding_ and decoding functions

     first step function serialise json in node
     next step in deserialise node struncture in list of pathes
     matcher check if input and output list_of_pathes and encoded_list equal

    :param list_of_pathes:
    :param description:
    :return:

    '''

    root_node = Node('root', (None, None))
    encode_list_of_pathes_into_node(root_node, list_of_pathes, description)
    decode_node_into_list_of_pathes(root_node, path=[])

    assert list_of_pathes == [val for val in ENCODED_PATH.values()]
Beispiel #6
0
 def rename(new_name):
     root_node = Node('root', (None, None))
     root_node.rename(new_name)
     return root_node.name
Beispiel #7
0
 def get_node_by_path(path):
     root_node = Node('root', (None, None))
     encode_list_of_pathes_into_node(root_node, list_of_pathes, description)
     output_node = root_node.get_node_by_path(path)
     return output_node