'Return the lists of installed tool dependencies and missing tool dependencies for a set of repositories
being installed into Galaxy.'

def get_installed_and_missing_tool_dependencies_for_repository(self, tool_dependencies_dict):

    installed_tool_dependencies = {}
    missing_tool_dependencies = {}
    if tool_dependencies_dict:
        tmp_tool_dependencies_dict = copy.deepcopy(tool_dependencies_dict)
        for (td_key, val) in tmp_tool_dependencies_dict.items():
            tool_dependency_status = self.install_model.ToolDependency.installation_status.NEVER_INSTALLED
            if (td_key == 'set_environment'):
                new_val = []
                for requirement_dict in val:
                    tool_dependency = tool_dependency_util.get_tool_dependency_by_name_version_type(self.app, requirement_dict.get('name', None), requirement_dict.get('version', None), requirement_dict.get('type', 'package'))
                    if tool_dependency:
                        tool_dependency_status = tool_dependency.status
                    requirement_dict['status'] = tool_dependency_status
                    new_val.append(requirement_dict)
                    if (tool_dependency_status in [self.install_model.ToolDependency.installation_status.INSTALLED]):
                        if (td_key in installed_tool_dependencies):
                            installed_tool_dependencies[td_key].extend(new_val)
                        else:
                            installed_tool_dependencies[td_key] = new_val
                    elif (td_key in missing_tool_dependencies):
                        missing_tool_dependencies[td_key].extend(new_val)
                    else:
                        missing_tool_dependencies[td_key] = new_val
            else:
                tool_dependency = tool_dependency_util.get_tool_dependency_by_name_version_type(self.app, val.get('name', None), val.get('version', None), val.get('type', 'package'))
                if tool_dependency:
                    tool_dependency_status = tool_dependency.status
                val['status'] = tool_dependency_status
            if (tool_dependency_status in [self.install_model.ToolDependency.installation_status.INSTALLED]):
                installed_tool_dependencies[td_key] = val
            else:
                missing_tool_dependencies[td_key] = val
    return (installed_tool_dependencies, missing_tool_dependencies)
