summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-02-15 14:58:22 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-04 23:18:17 +0000
commitd8cf70bf0f7320487b7f72b953ef929f6a1ba11e (patch)
treeeb65c112fb14414b531e31f60c6fed64a35de73a /scripts
parent27e172c3b63d002ef4376b29d0cb5e461ced3e58 (diff)
downloadpoky-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')
-rw-r--r--scripts/lib/wic/help.py2
-rw-r--r--scripts/lib/wic/partition.py13
-rw-r--r--scripts/lib/wic/plugin.py22
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py10
4 files changed, 20 insertions, 27 deletions
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 4aba12de75..196896c170 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -374,7 +374,7 @@ DESCRIPTION
374 This scheme is extensible - adding more hooks is a simple matter 374 This scheme is extensible - adding more hooks is a simple matter
375 of adding more plugin methods to SourcePlugin and derived classes. 375 of adding more plugin methods to SourcePlugin and derived classes.
376 The code that then needs to call the plugin methods uses 376 The code that then needs to call the plugin methods uses
377 plugin.get_source_plugin_methods() to find the method(s) needed by 377 plugin.get_plugin_methods() to find the method(s) needed by
378 the call; this is done by filling up a dict with keys containing 378 the call; this is done by filling up a dict with keys containing
379 the method names of interest - on success, these will be filled in 379 the method names of interest - on success, these will be filled in
380 with the actual methods. Please see the implementation for 380 with the actual methods. Please see the implementation for
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index d3cd5931f7..1f384be450 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -170,14 +170,11 @@ class Partition():
170 splitted = self.sourceparams.split(',') 170 splitted = self.sourceparams.split(',')
171 srcparams_dict = dict(par.split('=') for par in splitted if par) 171 srcparams_dict = dict(par.split('=') for par in splitted if par)
172 172
173 partition_methods = { 173 partition_methods = ["do_configure_partition", "do_stage_partition",
174 "do_stage_partition": None, 174 "do_prepare_partition"]
175 "do_prepare_partition": None, 175
176 "do_configure_partition": None 176 methods = PluginMgr.get_plugin_methods('source', self.source,
177 } 177 partition_methods)
178
179 methods = PluginMgr.get_source_plugin_methods(self.source,
180 partition_methods)
181 methods["do_configure_partition"](self, srcparams_dict, creator, 178 methods["do_configure_partition"](self, srcparams_dict, creator,
182 cr_workdir, oe_builddir, bootimg_dir, 179 cr_workdir, oe_builddir, bootimg_dir,
183 kernel_dir, native_sysroot) 180 kernel_dir, native_sysroot)
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
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index b93273e877..4ab195519a 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -198,11 +198,11 @@ class DirectPlugin(ImagerPlugin):
198 disk_name = self.parts[0].disk 198 disk_name = self.parts[0].disk
199 if source_plugin: 199 if source_plugin:
200 name = "do_install_disk" 200 name = "do_install_disk"
201 methods = PluginMgr.get_source_plugin_methods(source_plugin, 201 method = PluginMgr.get_plugin_methods('source', source_plugin,
202 {name: None}) 202 [name])[name]
203 methods["do_install_disk"](self._image, disk_name, self, self.workdir, 203 method(self._image, disk_name, self, self.workdir,
204 self.oe_builddir, self.bootimg_dir, 204 self.oe_builddir, self.bootimg_dir,
205 self.kernel_dir, self.native_sysroot) 205 self.kernel_dir, self.native_sysroot)
206 206
207 full_path = self._image.path 207 full_path = self._image.path
208 # Generate .bmap 208 # Generate .bmap