mirror of
https://github.com/certbot/certbot.git
synced 2026-06-05 14:54:24 -04:00
* Remove unsupported pylint disable options
* star-args removed in Pylint 1.4.3
* abstract-class-little-used removed in Pylint 1.4.3
* Fixes new lint errors
* Copy dummy-variable-rgx expression to new ignored-argument-names expression to ignore unused funtion arguments
* Notable changes
* Refactor to satisfy Pylint no-else-return warning
* Fix Pylint inconsistent-return-statements warning
* Refactor to satisfy consider-iterating-dictionary
* Remove methods with only super call to satisfy useless-super-delegation
* Refactor too-many-nested-statements where possible
* Suppress type checked errors where member is dynamically added (notably derived from josepy.JSONObjectWithFields)
* Remove None default of func parameter for ExitHandler and ErrorHandler
Resolves #5973
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""Contains UI methods for Nginx operations."""
|
|
import logging
|
|
|
|
import zope.component
|
|
|
|
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 Nginx 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 tags_list:
|
|
tags_list[-1] = tags_list[-1][:-1]
|
|
code, names = zope.component.getUtility(interfaces.IDisplay).checklist(
|
|
"Which server blocks would you like to modify?",
|
|
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
|