Skip to contentSkip to conversation

base.bbclass: in base_contains, check for var existance before using it

PATCH In review Chris Larson 3 participants 3 messages Jan 15, 2010 – Jan 26, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 base.bbclass: in base_contains, check for var existance before using it

From: Brian Pomerantz <[email protected]>

When using base_contains() to check for a string in a variable for a, if the variable is not defined an exception occurs. By checking the existance of the variable and returning false if it isn't there, a value can be checked for a variable regardless of whether or not it is defined.

---
 classes/base.bbclass |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
classes/base.bbclass +5 -2
index 384a67d..f67773a 100644
@@ -226,14 +226,17 @@ def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
         return falsevalue
 
 def base_contains(variable, checkvalues, truevalue, falsevalue, d):
+	val = bb.data.getVar(variable,d,1)
+	if not val:
+		return falsevalue
 	matches = 0
 	if type(checkvalues).__name__ == "str":
 		checkvalues = [checkvalues]
 	for value in checkvalues:
-		if bb.data.getVar(variable,d,1).find(value) != -1:	
+		if val.find(value) != -1:
 			matches = matches + 1
 	if matches == len(checkvalues):
-		return truevalue		
+		return truevalue
 	return falsevalue
 
 def base_both_contain(variable1, variable2, checkvalue, d):
Signature · 1 line
1.6.4.339.g527d
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Chris Larson

From: Brian Pomerantz <[email protected]>

When using base_contains() to check for a string in a variable for a, if the variable is not defined an exception occurs. By checking the existance of the variable and returning false if it isn't there, a value can be checked for a variable regardless of whether or not it is defined.

Quoted 36 lines
---
 classes/base.bbclass |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
classes/base.bbclass +5 -2
index 384a67d..f67773a 100644
@@ -226,14 +226,17 @@ def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
         return falsevalue
 
 def base_contains(variable, checkvalues, truevalue, falsevalue, d):
+	val = bb.data.getVar(variable,d,1)
+	if not val:
+		return falsevalue
 	matches = 0
 	if type(checkvalues).__name__ == "str":
 		checkvalues = [checkvalues]
 	for value in checkvalues:
-		if bb.data.getVar(variable,d,1).find(value) != -1:	
+		if val.find(value) != -1:
 			matches = matches + 1
 	if matches == len(checkvalues):
-		return truevalue		
+		return truevalue
 	return falsevalue
 
 def base_both_contain(variable1, variable2, checkvalue, d):
Signature · 7 lines
1.6.4.339.g527d


_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
Acked-by on v1 1/1
#2 lore raw
In reply to Chris Larson

Dnia piątek, 15 stycznia 2010 o 18:36:58 Chris Larson napisał(a):

Quoted 10 lines

From: Brian Pomerantz <[email protected]>

When using base_contains() to check for a string in a variable for a, if the variable is not defined an exception occurs. By checking the existance of the variable and returning false if it isn't there, a value can be checked for a variable regardless of whether or not it is defined.

Regards,

Signature · 3 lines
JID:      [email protected]
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz