# Source code for certbot_apache.display_ops

    """Contains UI methods for Apache operations."""
    import logging
    import os

    import zope.component

    from certbot import errors
    from certbot import interfaces

    import certbot.display.util as display_util

    logger = logging.getLogger(__name__)

    def select_vhost_multiple(vhosts):
        """Select multiple Vhosts to install the certificate for

        :param vhosts: Available Apache VirtualHosts
        :type vhosts: :class:`list` of type `~obj.Vhost`

        :returns: List of VirtualHosts
        :rtype: :class:`list`of type `~obj.Vhost`
        """
        if not vhosts:
            return list()
        tags_list = [vhost.display_repr()+"\n" for vhost in vhosts]
        # Remove the extra newline from the last entry
        if len(tags_list):
            tags_list[-1] = tags_list[-1][:-1]
        code, names = zope.component.getUtility(interfaces.IDisplay).checklist(
            "Which VirtualHosts would you like to install the wildcard certificate for?",
            tags=tags_list, force_interactive=True)
        if code == display_util.OK:
            return_vhosts = _reversemap_vhosts(names, vhosts)
            return return_vhosts
        return []

    def _reversemap_vhosts(names, vhosts):
        """Helper function for select_vhost_multiple for mapping string
        representations back to actual vhost objects"""
        return_vhosts = list()

        for selection in names:
            for vhost in vhosts:
                if vhost.display_repr().strip() == selection.strip():
                    return_vhosts.append(vhost)
        return return_vhosts

    def select_vhost(domain, vhosts):
        """Select an appropriate Apache Vhost.

        :param vhosts: Available Apache VirtualHosts
        :type vhosts: :class:`list` of type `~obj.Vhost`

        :returns: VirtualHost or `None`
        :rtype: `~obj.Vhost` or `None`

        """
        if not vhosts:
            return None
        code, tag = _vhost_menu(domain, vhosts)
        if code == display_util.OK:
            return vhosts[tag]
        else:
            return None