diff options
| author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-02-15 14:58:22 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-04 23:18:17 +0000 |
| commit | d8cf70bf0f7320487b7f72b953ef929f6a1ba11e (patch) | |
| tree | eb65c112fb14414b531e31f60c6fed64a35de73a /scripts/lib/wic/plugin.py | |
| parent | 27e172c3b63d002ef4376b29d0cb5e461ced3e58 (diff) | |
| download | poky-d8cf70bf0f7320487b7f72b953ef929f6a1ba11e.tar.gz | |
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 <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugin.py')
| -rw-r--r-- | scripts/lib/wic/plugin.py | 22 |
1 files changed, 9 insertions, 13 deletions
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: | |||
| 109 | return pluginbase.get_plugins(ptype) | 109 | return pluginbase.get_plugins(ptype) |
| 110 | 110 | ||
| 111 | @classmethod | 111 | @classmethod |
| 112 | def get_source_plugin_methods(cls, source_name, methods): | 112 | def get_plugin_methods(cls, ptype, pname, methods): |
| 113 | """ | 113 | """ |
| 114 | The methods param is a dict with the method names to find. On | 114 | The methods param is a dict with the method names to find. On |
| 115 | return, the dict values will be filled in with pointers to the | 115 | return, the dict values will be filled in with pointers to the |
| 116 | corresponding methods. If one or more methods are not found, | 116 | corresponding methods. If one or more methods are not found, |
| 117 | None is returned. | 117 | None is returned. |
| 118 | """ | 118 | """ |
| 119 | return_methods = None | 119 | result = {} |
| 120 | for _source_name, klass in cls.get_plugins('source').items(): | 120 | plugin = cls.get_plugins(ptype).get(pname) |
| 121 | if _source_name == source_name: | 121 | for method in methods: |
| 122 | for _method_name in methods: | 122 | if not hasattr(plugin, method): |
| 123 | if not hasattr(klass, _method_name): | 123 | raise WicError("Unimplemented %s plugin interface for: %s" % |
| 124 | logger.warning("Unimplemented %s source interface for: %s", | 124 | (method, pname)) |
| 125 | _method_name, _source_name) | 125 | result[method] = getattr(plugin, method) |
| 126 | return None | 126 | return result |
| 127 | func = getattr(klass, _method_name) | ||
| 128 | methods[_method_name] = func | ||
| 129 | return_methods = methods | ||
| 130 | return return_methods | ||
