[oe] [PATCH 1/3] base.bbclass: added oe_param_bool() method

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Thu May 27 12:41:09 UTC 2010


This new function works like dict's get() method but converts the
returned value to a boolean.

It is to be used to interpret e.g. 'apply=yes' parameters in SRC_URI.

Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
 classes/base.bbclass |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/classes/base.bbclass b/classes/base.bbclass
index 8bac509..21b5646 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -161,6 +161,16 @@ python base_do_fetch() {
 			raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
 }
 
+def oe_param_bool(cfg, field, dflt):
+	"""Lookup <field> in <cfg> map and convert it to a boolean; take 
+        <dflt> when this <field> does not exist"""
+	v = ("%s" % cfg.get(field, dflt)).lower()
+	if v in ['yes', 'y', 'true', 't', '1']:
+		return True
+	if v in ['no', 'n', 'false', 'f', '0']:
+		return False
+	raise bb.build.FuncFailed("Can not convert '%s' to boolean" % v)
+
 def oe_unpack_file(file, data, url = None):
 	import subprocess
 	if not url:
-- 
1.7.0.1





More information about the Openembedded-devel mailing list