Merge pull request #2515 from thanatos/class-advice-impossible

Class advice impossible
This commit is contained in:
Peter Eckersley
2016-02-23 17:25:56 -08:00
15 changed files with 28 additions and 33 deletions
@@ -9,10 +9,10 @@ from letsencrypt import interfaces
from letsencrypt.plugins import common from letsencrypt.plugins import common
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin): class Authenticator(common.Plugin):
"""Example Authenticator.""" """Example Authenticator."""
zope.interface.implements(interfaces.IAuthenticator)
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Example Authenticator plugin" description = "Example Authenticator plugin"
@@ -20,10 +20,10 @@ class Authenticator(common.Plugin):
# "self" as first argument, e.g. def prepare(self)... # "self" as first argument, e.g. def prepare(self)...
@zope.interface.implementer(interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class Installer(common.Plugin): class Installer(common.Plugin):
"""Example Installer.""" """Example Installer."""
zope.interface.implements(interfaces.IInstaller)
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Example Installer plugin" description = "Example Installer plugin"
@@ -60,6 +60,8 @@ logger = logging.getLogger(__name__)
# sites-available doesn't allow immediate find_dir search even with save() # sites-available doesn't allow immediate find_dir search even with save()
# and load() # and load()
@zope.interface.implementer(interfaces.IAuthenticator, interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class ApacheConfigurator(augeas_configurator.AugeasConfigurator): class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
# pylint: disable=too-many-instance-attributes,too-many-public-methods # pylint: disable=too-many-instance-attributes,too-many-public-methods
"""Apache configurator. """Apache configurator.
@@ -80,8 +82,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:ivar dict assoc: Mapping between domains and vhosts :ivar dict assoc: Mapping between domains and vhosts
""" """
zope.interface.implements(interfaces.IAuthenticator, interfaces.IInstaller)
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Apache Web Server - Alpha" description = "Apache Web Server - Alpha"
@@ -34,11 +34,10 @@ SHARED_MODULES = {
"vhost_alias"} "vhost_alias"}
@zope.interface.implementer(interfaces.IConfiguratorProxy)
class Proxy(apache_common.Proxy): class Proxy(apache_common.Proxy):
"""Wraps the ApacheConfigurator for Apache 2.4 tests""" """Wraps the ApacheConfigurator for Apache 2.4 tests"""
zope.interface.implements(interfaces.IConfiguratorProxy)
def __init__(self, args): def __init__(self, args):
"""Initializes the plugin with the given command line args""" """Initializes the plugin with the given command line args"""
super(Proxy, self).__init__(args) super(Proxy, self).__init__(args)
@@ -19,12 +19,11 @@ APACHE_VERSION_REGEX = re.compile(r"Apache/([0-9\.]*)", re.IGNORECASE)
APACHE_COMMANDS = ["apachectl", "a2enmod", "a2dismod"] APACHE_COMMANDS = ["apachectl", "a2enmod", "a2dismod"]
@zope.interface.implementer(interfaces.IConfiguratorProxy)
class Proxy(configurators_common.Proxy): class Proxy(configurators_common.Proxy):
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes
"""A common base for Apache test configurators""" """A common base for Apache test configurators"""
zope.interface.implements(interfaces.IConfiguratorProxy)
def __init__(self, args): def __init__(self, args):
"""Initializes the plugin with the given command line args""" """Initializes the plugin with the given command line args"""
super(Proxy, self).__init__(args) super(Proxy, self).__init__(args)
@@ -12,10 +12,10 @@ from letsencrypt import interfaces
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IValidator)
class Validator(object): class Validator(object):
# pylint: disable=no-self-use # pylint: disable=no-self-use
"""Collection of functions to test a live webserver's configuration""" """Collection of functions to test a live webserver's configuration"""
zope.interface.implements(interfaces.IValidator)
def certificate(self, cert, name, alt_host=None, port=443): def certificate(self, cert, name, alt_host=None, port=443):
"""Verifies the certificate presented at name is cert""" """Verifies the certificate presented at name is cert"""
@@ -31,6 +31,8 @@ from letsencrypt_nginx import parser
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IAuthenticator, interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class NginxConfigurator(common.Plugin): class NginxConfigurator(common.Plugin):
# pylint: disable=too-many-instance-attributes,too-many-public-methods # pylint: disable=too-many-instance-attributes,too-many-public-methods
"""Nginx configurator. """Nginx configurator.
@@ -52,8 +54,6 @@ class NginxConfigurator(common.Plugin):
:ivar tup version: version of Nginx :ivar tup version: version of Nginx
""" """
zope.interface.implements(interfaces.IAuthenticator, interfaces.IInstaller)
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Nginx Web Server - currently doesn't work" description = "Nginx Web Server - currently doesn't work"
+1 -1
View File
@@ -11,6 +11,7 @@ from letsencrypt import interfaces
from letsencrypt import le_util from letsencrypt import le_util
@zope.interface.implementer(interfaces.IConfig)
class NamespaceConfig(object): class NamespaceConfig(object):
"""Configuration wrapper around :class:`argparse.Namespace`. """Configuration wrapper around :class:`argparse.Namespace`.
@@ -32,7 +33,6 @@ class NamespaceConfig(object):
:type namespace: :class:`argparse.Namespace` :type namespace: :class:`argparse.Namespace`
""" """
zope.interface.implements(interfaces.IConfig)
def __init__(self, namespace): def __init__(self, namespace):
self.namespace = namespace self.namespace = namespace
+1 -1
View File
@@ -9,6 +9,7 @@ from letsencrypt import interfaces
from letsencrypt import proof_of_possession from letsencrypt import proof_of_possession
@zope.interface.implementer(interfaces.IAuthenticator)
class ContinuityAuthenticator(object): class ContinuityAuthenticator(object):
"""IAuthenticator for """IAuthenticator for
:const:`~acme.challenges.ContinuityChallenge` class challenges. :const:`~acme.challenges.ContinuityChallenge` class challenges.
@@ -18,7 +19,6 @@ class ContinuityAuthenticator(object):
:class:`letsencrypt.proof_of_possession.Proof_of_Possession` :class:`letsencrypt.proof_of_possession.Proof_of_Possession`
""" """
zope.interface.implements(interfaces.IAuthenticator)
# This will have an installer soon for get_key/cert purposes # This will have an installer soon for get_key/cert purposes
def __init__(self, config, installer): # pylint: disable=unused-argument def __init__(self, config, installer): # pylint: disable=unused-argument
+3 -6
View File
@@ -36,11 +36,10 @@ def _wrap_lines(msg):
fixed_l.append(textwrap.fill(line, 80)) fixed_l.append(textwrap.fill(line, 80))
return os.linesep.join(fixed_l) return os.linesep.join(fixed_l)
@zope.interface.implementer(interfaces.IDisplay)
class NcursesDisplay(object): class NcursesDisplay(object):
"""Ncurses-based display.""" """Ncurses-based display."""
zope.interface.implements(interfaces.IDisplay)
def __init__(self, width=WIDTH, height=HEIGHT): def __init__(self, width=WIDTH, height=HEIGHT):
super(NcursesDisplay, self).__init__() super(NcursesDisplay, self).__init__()
self.dialog = dialog.Dialog() self.dialog = dialog.Dialog()
@@ -176,11 +175,10 @@ class NcursesDisplay(object):
message, width=self.width, height=self.height, choices=choices) message, width=self.width, height=self.height, choices=choices)
@zope.interface.implementer(interfaces.IDisplay)
class FileDisplay(object): class FileDisplay(object):
"""File-based display.""" """File-based display."""
zope.interface.implements(interfaces.IDisplay)
def __init__(self, outfile): def __init__(self, outfile):
super(FileDisplay, self).__init__() super(FileDisplay, self).__init__()
self.outfile = outfile self.outfile = outfile
@@ -411,11 +409,10 @@ class FileDisplay(object):
return OK, selection return OK, selection
@zope.interface.implementer(interfaces.IDisplay)
class NoninteractiveDisplay(object): class NoninteractiveDisplay(object):
"""An iDisplay implementation that never asks for interactive user input""" """An iDisplay implementation that never asks for interactive user input"""
zope.interface.implements(interfaces.IDisplay)
def __init__(self, outfile): def __init__(self, outfile):
super(NoninteractiveDisplay, self).__init__() super(NoninteractiveDisplay, self).__init__()
self.outfile = outfile self.outfile = outfile
+3 -3
View File
@@ -31,11 +31,11 @@ hostname_regex = re.compile(
r"^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*[a-z]+$", re.IGNORECASE) r"^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*[a-z]+$", re.IGNORECASE)
@zope.interface.implementer(interfaces.IPlugin)
class Plugin(object): class Plugin(object):
"""Generic plugin.""" """Generic plugin."""
zope.interface.implements(interfaces.IPlugin) # provider is not inherited, subclasses must define it on their own
# classProvides is not inherited, subclasses must define it on their own # @zope.interface.provider(interfaces.IPluginFactory)
#zope.interface.classProvides(interfaces.IPluginFactory)
def __init__(self, config, name): def __init__(self, config, name):
self.config = config self.config = config
+2 -2
View File
@@ -23,6 +23,8 @@ from letsencrypt.plugins import common
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin): class Authenticator(common.Plugin):
"""Manual Authenticator. """Manual Authenticator.
@@ -34,8 +36,6 @@ class Authenticator(common.Plugin):
.. todo:: Support for `~.challenges.TLSSNI01`. .. todo:: Support for `~.challenges.TLSSNI01`.
""" """
zope.interface.implements(interfaces.IAuthenticator)
zope.interface.classProvides(interfaces.IPluginFactory)
hidden = True hidden = True
description = "Manually configure an HTTP server" description = "Manually configure an HTTP server"
+2 -2
View File
@@ -11,10 +11,10 @@ from letsencrypt.plugins import common
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class Installer(common.Plugin): class Installer(common.Plugin):
"""Null installer.""" """Null installer."""
zope.interface.implements(interfaces.IInstaller)
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Null Installer" description = "Null Installer"
hidden = True hidden = True
+2 -2
View File
@@ -135,6 +135,8 @@ def supported_challenges_validator(data):
return data return data
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin): class Authenticator(common.Plugin):
"""Standalone Authenticator. """Standalone Authenticator.
@@ -143,8 +145,6 @@ class Authenticator(common.Plugin):
challenges from the certificate authority. Therefore, it does not challenges from the certificate authority. Therefore, it does not
rely on any existing server program. rely on any existing server program.
""" """
zope.interface.implements(interfaces.IAuthenticator)
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Automatically use a temporary webserver" description = "Automatically use a temporary webserver"
+2 -2
View File
@@ -17,10 +17,10 @@ from letsencrypt.plugins import common
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin): class Authenticator(common.Plugin):
"""Webroot Authenticator.""" """Webroot Authenticator."""
zope.interface.implements(interfaces.IAuthenticator)
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Webroot Authenticator" description = "Webroot Authenticator"
+1 -1
View File
@@ -17,6 +17,7 @@ from letsencrypt import le_util
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IReporter)
class Reporter(object): class Reporter(object):
"""Collects and displays information to the user. """Collects and displays information to the user.
@@ -24,7 +25,6 @@ class Reporter(object):
the user. the user.
""" """
zope.interface.implements(interfaces.IReporter)
HIGH_PRIORITY = 0 HIGH_PRIORITY = 0
"""High priority constant. See `add_message`.""" """High priority constant. See `add_message`."""