From: Ivan Frade Date: Sun, 6 Sep 2009 21:26:51 +0000 (+0300) Subject: Set util class to create unique list of artists or albums X-Git-Tag: mussorgsky-0.3-1~15 X-Git-Url: https://vcs.maemo.org/git/?p=mussorgsky;a=commitdiff_plain;h=3567f08b71c6df0c770f7479156380a2fd0cf53c Set util class to create unique list of artists or albums --- diff --git a/src/utils.py b/src/utils.py index 0d7d622..9eb0126 100644 --- a/src/utils.py +++ b/src/utils.py @@ -31,3 +31,28 @@ class UrllibWrapper (): return opener.open (request).read () except: return None + + + +class Set: + + def __init__ (self): + self.d = {} + self.k = None + + def insert (self, element): + if (not self.d.has_key (element)): + print "insert", element + self.d[element] = 1 + self.k = None + + def as_list (self): + if (self.k): + return self.k + + self.k = self.d.keys () + self.k.sort () + return self.k + + +