'Retrieve necessary information from the received repository\'s metadata to populate the
containers_dict for display.  This method is called only from Galaxy (not the tool shed)
when displaying repository dependencies for installed repositories and when displaying
them for uninstalled repositories that are being reinstalled.'

def populate_containers_dict_from_repository_metadata(self, tool_shed_url, tool_path, repository, reinstalling=False, required_repo_info_dicts=None):

    metadata = repository.metadata
    if metadata:
        datatypes = metadata.get('datatypes', None)
        invalid_tools = metadata.get('invalid_tools', None)
        if repository.has_readme_files:
            if (reinstalling or (repository.status not in [self.app.install_model.ToolShedRepository.installation_status.DEACTIVATED, self.app.install_model.ToolShedRepository.installation_status.INSTALLED])):
                tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry(self.app, tool_shed_url)
                params = dict(name=str(repository.name), owner=str(repository.owner), changeset_revision=str(repository.installed_changeset_revision))
                pathspec = ['repository', 'get_readme_files']
                raw_text = util.url_get(tool_shed_url, password_mgr=self.app.tool_shed_registry.url_auth(tool_shed_url), pathspec=pathspec, params=params)
                readme_files_dict = json.loads(raw_text)
            else:
                readme_files_dict = readme_util.build_readme_files_dict(self.app, repository, repository.changeset_revision, repository.metadata, tool_path)
        else:
            readme_files_dict = None
        (installed_repository_dependencies, missing_repository_dependencies) = self.app.installed_repository_manager.get_installed_and_missing_repository_dependencies(repository)
        repository_tool_dependencies = metadata.get('tool_dependencies', None)
        repository_invalid_tool_dependencies = metadata.get('invalid_tool_dependencies', None)
        if (repository_invalid_tool_dependencies is not None):
            if (repository_tool_dependencies is None):
                repository_tool_dependencies = {}
            repository_tool_dependencies.update(repository_invalid_tool_dependencies)
        (repository_installed_tool_dependencies, repository_missing_tool_dependencies) = self.get_installed_and_missing_tool_dependencies_for_installed_repository(repository, repository_tool_dependencies)
        if reinstalling:
            (installed_tool_dependencies, missing_tool_dependencies) = self.populate_tool_dependencies_dicts(tool_shed_url, tool_path, repository_installed_tool_dependencies, repository_missing_tool_dependencies, required_repo_info_dicts)
        else:
            installed_tool_dependencies = repository_installed_tool_dependencies
            missing_tool_dependencies = repository_missing_tool_dependencies
        valid_tools = metadata.get('tools', None)
        workflows = metadata.get('workflows', None)
        valid_data_managers = None
        invalid_data_managers = None
        data_managers_errors = None
        if ('data_manager' in metadata):
            valid_data_managers = metadata['data_manager'].get('data_managers', None)
            invalid_data_managers = metadata['data_manager'].get('invalid_data_managers', None)
            data_managers_errors = metadata['data_manager'].get('messages', None)
        gucm = GalaxyUtilityContainerManager(self.app)
        containers_dict = gucm.build_repository_containers(repository=repository, datatypes=datatypes, invalid_tools=invalid_tools, missing_repository_dependencies=missing_repository_dependencies, missing_tool_dependencies=missing_tool_dependencies, readme_files_dict=readme_files_dict, repository_dependencies=installed_repository_dependencies, tool_dependencies=installed_tool_dependencies, valid_tools=valid_tools, workflows=workflows, valid_data_managers=valid_data_managers, invalid_data_managers=invalid_data_managers, data_managers_errors=data_managers_errors, new_install=False, reinstalling=reinstalling)
    else:
        containers_dict = dict(datatypes=None, invalid_tools=None, readme_files_dict=None, repository_dependencies=None, tool_dependencies=None, valid_tools=None, workflows=None)
    return containers_dict
