From: Chris Larson Date: Sun, 17 Oct 2010 05:32:06 +0000 (-0700) Subject: utils, oe.utils: add 'uniq' function X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16011461a11c3408a81983b5f719e5e9da9c7ff6;p=openembedded.git utils, oe.utils: add 'uniq' function Ignore duplicates in an iterable. Signed-off-by: Chris Larson --- diff --git a/classes/utils.bbclass b/classes/utils.bbclass index 81417fca27..2c6a59d543 100644 --- a/classes/utils.bbclass +++ b/classes/utils.bbclass @@ -1,4 +1,8 @@ # For compatibility +def uniq(iterable): + import oe.utils + return oe.utils.uniq(iterable) + def base_path_join(a, *p): return oe.path.join(a, *p) diff --git a/lib/oe/utils.py b/lib/oe/utils.py index 3469700726..2169ed212e 100644 --- a/lib/oe/utils.py +++ b/lib/oe/utils.py @@ -1,3 +1,10 @@ +def uniq(iterable): + seen = set() + for i in iterable: + if i not in seen: + yield i + seen.add(i) + def read_file(filename): try: f = file( filename, "r" )