From 16011461a11c3408a81983b5f719e5e9da9c7ff6 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Sat, 16 Oct 2010 22:32:06 -0700 Subject: utils, oe.utils: add 'uniq' function Ignore duplicates in an iterable. Signed-off-by: Chris Larson --- lib/oe/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') 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" ) -- cgit 1.2.3-korg