[oe-commits] Chris Larson : utils, oe.utils: add 'uniq' function
git version control
git at git.openembedded.org
Sun Oct 17 05:57:53 UTC 2010
Module: openembedded.git
Branch: master
Commit: 16011461a11c3408a81983b5f719e5e9da9c7ff6
URL: http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=16011461a11c3408a81983b5f719e5e9da9c7ff6
Author: Chris Larson <chris_larson at mentor.com>
Date: Sat Oct 16 22:32:06 2010 -0700
utils, oe.utils: add 'uniq' function
Ignore duplicates in an iterable.
Signed-off-by: Chris Larson <chris_larson at mentor.com>
---
classes/utils.bbclass | 4 ++++
lib/oe/utils.py | 7 +++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/classes/utils.bbclass b/classes/utils.bbclass
index 81417fc..2c6a59d 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 3469700..2169ed2 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" )
More information about the Openembedded-commits
mailing list