diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-06-13 14:22:01 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-14 10:18:20 +0100 |
commit | 4c1ded3ddbd04ad1640620ec1348831692a93dbe (patch) | |
tree | f9ed636af8c119de0ee9445e45a9e78617563d7e /scripts/lib | |
parent | f0dcf39d52185430422cb0c94c7fe99c12764acd (diff) | |
download | openembedded-core-4c1ded3ddbd04ad1640620ec1348831692a93dbe.tar.gz openembedded-core-4c1ded3ddbd04ad1640620ec1348831692a93dbe.tar.bz2 openembedded-core-4c1ded3ddbd04ad1640620ec1348831692a93dbe.zip |
wic: add Disk._prop helper
Added generic helper to use in property methods to
access commands in a lazy manner.
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/wic/engine.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index f8f2844cf6..e3701c442e 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py @@ -267,13 +267,18 @@ class Disk: return self._partitions + def _prop(self, name): + """Get path to the executable in a lazy way.""" + aname = "_%s" % name + if getattr(self, aname) is None: + setattr(self, aname, find_executable(name, self.paths)) + if not getattr(self, aname): + raise WicError("Can't find executable {}".format(name)) + return getattr(self, aname) + @property def mdir(self): - if self._mdir is None: - self._mdir = find_executable("mdir", self.paths) - if not self._mdir: - raise WicError("Can't find executable mdir") - return self._mdir + return self._prop('mdir') def _get_part_image(self, pnum): if pnum not in self.partitions: |