diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-08-25 23:12:22 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-27 22:30:07 +0100 |
commit | ff0bbdafa466aa006dc91a32814ecbe7ae093724 (patch) | |
tree | 3792d303677ec150a98e98f452548b7306c51f32 /scripts | |
parent | 051a3a61d830f6484e65e234fbd4dbcc56eb7f41 (diff) | |
download | poky-ff0bbdafa466aa006dc91a32814ecbe7ae093724.tar.gz |
wic: reimplement getting paths of used tools
So far every used tool have to have separate property and
private attribute in the Disk class. This is too verbose,
considering that there will be much more tools used.
Reimplemented getting tools paths using custom __getattr__
method. This is much more compact and readable.
(From OE-Core rev: d1a831a9870bc31e936eb480485b28f1ffc13080)
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/engine.py | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index 2dc2fd5ed4..b23dd65de2 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -236,10 +236,6 @@ class Disk: | |||
236 | self.imagepath = imagepath | 236 | self.imagepath = imagepath |
237 | self.native_sysroot = native_sysroot | 237 | self.native_sysroot = native_sysroot |
238 | self._partitions = None | 238 | self._partitions = None |
239 | self._mdir = None | ||
240 | self._mcopy = None | ||
241 | self._mdel = None | ||
242 | self._mdeltree = None | ||
243 | self._partimages = {} | 239 | self._partimages = {} |
244 | 240 | ||
245 | # find parted | 241 | # find parted |
@@ -270,30 +266,16 @@ class Disk: | |||
270 | 266 | ||
271 | return self._partitions | 267 | return self._partitions |
272 | 268 | ||
273 | def _prop(self, name): | 269 | def __getattr__(self, name): |
274 | """Get path to the executable in a lazy way.""" | 270 | """Get path to the executable in a lazy way.""" |
275 | aname = "_%s" % name | 271 | if name in ("mdir", "mcopy", "mdel", "mdeltree"): |
276 | if getattr(self, aname) is None: | 272 | aname = "_%s" % name |
277 | setattr(self, aname, find_executable(name, self.paths)) | 273 | if aname not in self.__dict__: |
278 | if not getattr(self, aname): | 274 | setattr(self, aname, find_executable(name, self.paths)) |
279 | raise WicError("Can't find executable {}".format(name)) | 275 | if aname not in self.__dict__: |
280 | return getattr(self, aname) | 276 | raise WicError("Can't find executable {}".format(name)) |
281 | 277 | return self.__dict__[aname] | |
282 | @property | 278 | return self.__dict__[name] |
283 | def mdir(self): | ||
284 | return self._prop('mdir') | ||
285 | |||
286 | @property | ||
287 | def mcopy(self): | ||
288 | return self._prop("mcopy") | ||
289 | |||
290 | @property | ||
291 | def mdel(self): | ||
292 | return self._prop("mdel") | ||
293 | |||
294 | @property | ||
295 | def mdeltree(self): | ||
296 | return self._prop("mdeltree") | ||
297 | 279 | ||
298 | def _get_part_image(self, pnum): | 280 | def _get_part_image(self, pnum): |
299 | if pnum not in self.partitions: | 281 | if pnum not in self.partitions: |