def prompt_rb_repository(self, tool_name, repository_info, api_root):
        """Interactively prompt to select a matching repository.

        The user is prompted to choose a matching repository found on the
        Review Board server.
        """
        # Go through each matching repo and prompt for a selection. If a
        # selection is made, immediately return the selected repo.
        for repository_page in api_root.get_repositories().all_pages:
            repo_paths = {}

            for repository in repository_page:
                if repository.tool != tool_name:
                    continue

                repo_paths[repository['path']] = repository

                if 'mirror_path' in repository:
                    repo_paths[repository['mirror_path']] = repository

            closest_path = difflib.get_close_matches(repository_info.path,
                                                     six.iterkeys(repo_paths),
                                                     n=4, cutoff=0.4)

            for path in closest_path:
                repo = repo_paths[path]
                question = ('Use the %s repository "%s" (%s)?'
                            % (tool_name, repo['name'], repo['path']))

                if confirm(question):
                    return repo

        return None
dataset/ETHPy150Open reviewboard/rbtools/rbtools/commands/setup_repo.py/SetupRepo.prompt_rb_repository/original