From d8cf70bf0f7320487b7f72b953ef929f6a1ba11e Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 15 Feb 2017 14:58:22 +0200 Subject: wic: reimplement PluginMgr.get_plugin_methods Simplified the implementation of get_plugin_methods: - get rid of looping over the dicrtionary, used access by key instead - get rid of filling a dictionary that passed as a parameter (From OE-Core rev: 875d4eede61b548d64f426c2ef077cc17e50cd45) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- scripts/lib/wic/plugin.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'scripts/lib/wic/plugin.py') diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py index 064243dc9d..c200822af7 100644 --- a/scripts/lib/wic/plugin.py +++ b/scripts/lib/wic/plugin.py @@ -109,22 +109,18 @@ class PluginMgr: return pluginbase.get_plugins(ptype) @classmethod - def get_source_plugin_methods(cls, source_name, methods): + def get_plugin_methods(cls, ptype, pname, methods): """ The methods param is a dict with the method names to find. On return, the dict values will be filled in with pointers to the corresponding methods. If one or more methods are not found, None is returned. """ - return_methods = None - for _source_name, klass in cls.get_plugins('source').items(): - if _source_name == source_name: - for _method_name in methods: - if not hasattr(klass, _method_name): - logger.warning("Unimplemented %s source interface for: %s", - _method_name, _source_name) - return None - func = getattr(klass, _method_name) - methods[_method_name] = func - return_methods = methods - return return_methods + result = {} + plugin = cls.get_plugins(ptype).get(pname) + for method in methods: + if not hasattr(plugin, method): + raise WicError("Unimplemented %s plugin interface for: %s" % + (method, pname)) + result[method] = getattr(plugin, method) + return result -- cgit v1.2.3-54-g00ecf