From fc5a5af7bc3619f575988a75efc0c4fe15478b2d Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Wed, 5 Sep 2018 15:16:17 +0800 Subject: oe/utils.py: Add vartrue() It can be used to simplify code like: "${@['iffalse', 'iftrue'][var]}" Signed-off-by: Robert Yang Signed-off-by: Richard Purdie --- meta/lib/oe/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'meta/lib/oe') diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index fbda7035f1..93b0763b0a 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py @@ -25,6 +25,13 @@ def conditional(variable, checkvalue, truevalue, falsevalue, d): else: return falsevalue +def vartrue(var, iftrue, iffalse, d): + import oe.types + if oe.types.boolean(d.getVar(var)): + return iftrue + else: + return iffalse + def less_or_equal(variable, checkvalue, truevalue, falsevalue, d): if float(d.getVar(variable)) <= float(checkvalue): return truevalue @@ -467,3 +474,4 @@ class ImageQAFailed(bb.build.FuncFailed): msg = msg + ' (%s)' % self.description return msg + -- cgit 1.2.3-korg