@staticmethod<EOL><INDENT>def _workflow_node_structure(node_results):<DEDENT>
<EOL>node_list_pos = {}<EOL>for i, node_result in enumerate(node_results):<EOL><INDENT>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>node_result['<STR_LIT>'.format(rel)] = []<EOL><DEDENT>node_list_pos[node_result['<STR_LIT:id>']] = i<EOL><DEDENT>for node_result in node_results:<EOL><INDENT>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>for sub_node_id in node_result['<STR_LIT>'.format(rel)]:<EOL><INDENT>j = node_list_pos[sub_node_id]<EOL>node_results[j]['<STR_LIT>'.format(rel)].append(<EOL>node_result['<STR_LIT:id>'])<EOL><DEDENT><DEDENT><DEDENT>root_nodes = []<EOL>for node_result in node_results:<EOL><INDENT>is_root = True<EOL>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>if node_result['<STR_LIT>'.format(rel)] != []:<EOL><INDENT>is_root = False<EOL>break<EOL><DEDENT><DEDENT>if is_root:<EOL><INDENT>root_nodes.append(node_result['<STR_LIT:id>'])<EOL><DEDENT><DEDENT>def branch_schema(node_id):<EOL><INDENT>i = node_list_pos[node_id]<EOL>node_dict = node_results[i]<EOL>ret_dict = {"<STR_LIT:id>": node_id}<EOL>for fd in NODE_STANDARD_FIELDS:<EOL><INDENT>val = node_dict.get(fd, None)<EOL>if val is not None:<EOL><INDENT>if fd == '<STR_LIT>':<EOL><INDENT>job_type = node_dict['<STR_LIT>'][<EOL>'<STR_LIT>']['<STR_LIT>']<EOL>ujt_key = JOB_TYPES[job_type]<EOL>ret_dict[ujt_key] = val<EOL><DEDENT>else:<EOL><INDENT>ret_dict[fd] = val<EOL><DEDENT><DEDENT><DEDENT>for rel in ['<STR_LIT:success>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>sub_node_id_list = node_dict['<STR_LIT>'.format(rel)]<EOL>if len(sub_node_id_list) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>relationship_name = '<STR_LIT>'.format(rel)<EOL>ret_dict[relationship_name] = []<EOL>for sub_node_id in sub_node_id_list:<EOL><INDENT>ret_dict[relationship_name].append(<EOL>branch_schema(sub_node_id))<EOL><DEDENT><DEDENT>return ret_dict<EOL><DEDENT>schema_dict = []<EOL>for root_node_id in root_nodes:<EOL><INDENT>schema_dict.append(branch_schema(root_node_id))<EOL><DEDENT>return schema_dict<EOL>
Takes the list results from the API in `node_results` and
translates this data into a dictionary organized in a
human-readable heirarchial structure