utils, oe.utils: add 'uniq' function
authorChris Larson <chris_larson@mentor.com>
Sun, 17 Oct 2010 05:32:06 +0000 (22:32 -0700)
committerChris Larson <chris_larson@mentor.com>
Sun, 17 Oct 2010 05:32:07 +0000 (22:32 -0700)
Ignore duplicates in an iterable.

Signed-off-by: Chris Larson <chris_larson@mentor.com>
classes/utils.bbclass
lib/oe/utils.py

index 81417fc..2c6a59d 100644 (file)
@@ -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)
 
index 3469700..2169ed2 100644 (file)
@@ -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" )