'When installing a repository that contains tools, all tools must
currently be defined within the same tool section in the tool panel or
outside of any sections.'

def generate_tool_panel_dict_for_new_install(self, tool_dicts, tool_section=None):

    tool_panel_dict = {}
    if tool_section:
        section_id = tool_section.id
        section_name = tool_section.name
        section_version = (tool_section.version or '')
    else:
        section_id = ''
        section_name = ''
        section_version = ''
    for tool_dict in tool_dicts:
        if tool_dict.get('add_to_tool_panel', True):
            guid = tool_dict['guid']
            tool_config = tool_dict['tool_config']
            tool_section_dict = dict(tool_config=tool_config, id=section_id, name=section_name, version=section_version)
            if (guid in tool_panel_dict):
                tool_panel_dict[guid].append(tool_section_dict)
            else:
                tool_panel_dict[guid] = [tool_section_dict]
    return tool_panel_dict
