From patchwork Tue Jan 19 20:01:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [oe] base.bbclass: add 'any' and 'all' functions. Date: Tue, 19 Jan 2010 10:01:07 -0000 From: Christopher Larson X-Patchwork-Id: 1485 Message-Id: <1263931267-18470-1-git-send-email-clarson@mvista.com> To: openembedded-devel@lists.openembedded.org Python 2.5+ has these functions built-in, but we don't yet require 2.5+. Signed-off-by: Chris Larson --- classes/base.bbclass | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/classes/base.bbclass b/classes/base.bbclass index 4d25258..dc56282 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -1,5 +1,20 @@ BB_DEFAULT_TASK ?= "build" +# Useful Python 2.5+ built-in functions +def any(iterable): + """ Return True if any element of the iterable is true. If the iterable is empty, return False. """ + for element in iterable: + if element: + return True + return False + +def all(iterable): + """ Return True if all elements of the iterable are true (or if the iterable is empty). """ + for element in iterable: + if not element: + return False + return True + python () { env = {} for v in d.keys():