Python list to tree
6 Python code examples are found related to "
list to tree".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: collectsphere.py From collectsphere with MIT License | 5 votes |
def convert_folder_tree_to_list(folder_tree): result = list() for leaf in folder_tree: if leaf._wsdlName == "Folder": result.extend(convert_folder_tree_to_list(leaf.childEntity)) else: result.append(leaf) return result
Example 2
Source File: svo.py From py-nltk-svo with MIT License | 5 votes |
def List_To_Tree(self, lst): if (not isinstance(lst, basestring)): if (len(lst) == 2 and isinstance(lst[0], str) and isinstance(lst[1], str)): lst = Tree(str(lst[0]).split('+')[0], [str(lst[1])]) elif (isinstance(lst[0], str) and not isinstance(lst[1], str)): lst = Tree(str(lst[0]).split('+')[0], map(self.List_To_Tree, lst[1: len(lst)])) return lst
Example 3
Source File: output.py From ladybug-dynamo with GNU General Public License v3.0 | 5 votes |
def list_to_tree(input): """Replicate method for Grashopper library. This is a workaround to use th exact same code in bot libraries. """ return input
Example 4
Source File: p2_puzzle_in_merkle_tree.py From wallets with Apache License 2.0 | 5 votes |
def list_to_tree(items): size = len(items) if size == 1: return items[0], 0 if size & 1: items.append(items[-1]) size += 1 halfway_index = size >> 1 left_node, left_height = list_to_tree(items[:halfway_index]) right_node, right_height = list_to_tree(items[halfway_index:]) return (left_node, right_node), max(left_height, right_height) + 1
Example 5
Source File: programs.py From XNM-Net with MIT License | 5 votes |
def list_to_tree(program_list): def build_subtree(cur): return { 'function': cur['function'], 'value_inputs': [x for x in cur['value_inputs']], 'inputs': [build_subtree(program_list[i]) for i in cur['inputs']], } return build_subtree(program_list[-1])
Example 6
Source File: noder.py From catcli with GNU General Public License v3.0 | 5 votes |
def list_to_tree(self, parent, names): '''convert list of files to a tree''' if not names: return r = anytree.resolver.Resolver('name') for name in names: name = name.rstrip(os.sep) self._add_entry(name, parent, r) ############################################################### # diverse ###############################################################