Store plugin parameters on the plugin itself

This allows us to access these from the checker module as well.
This commit is contained in:
Ian Cordasco 2016-02-26 08:21:09 -06:00
parent 62a78f4a97
commit 6a15bd00b5

View file

@ -35,6 +35,7 @@ class Plugin(object):
self.name = name
self.entry_point = entry_point
self._plugin = None
self._parameters = None
def __repr__(self):
"""Provide an easy to read description of the current plugin."""
@ -42,6 +43,13 @@ class Plugin(object):
self.name, self.entry_point
)
@property
def parameters(self):
"""List of arguments that need to be passed to the plugin."""
if self._parameters is None:
self._parameters = utils.parameters_for(self)
return self._parameters
@property
def plugin(self):
"""The loaded (and cached) plugin associated with the entry-point.
@ -303,8 +311,7 @@ class Checkers(PluginTypeManager):
Find all checker plugins that are expecting a specific argument.
"""
for plugin in self.plugins.values():
parameters = utils.parameters_for(plugin)
if argument_name == parameters[0]:
if argument_name == plugin.parameters[0]:
yield plugin
@property