[Piuparts-commits] rev 448 - trunk/piupartslib

Lars Wirzenius lars at alioth.debian.org
Thu Jun 25 17:17:29 UTC 2009


Author: lars
Date: 2009-06-25 17:17:28 +0000 (Thu, 25 Jun 2009)
New Revision: 448

Modified:
   trunk/piupartslib/packagesdb.py
Log:
Simplified unique() function by request of Holger.

Modified: trunk/piupartslib/packagesdb.py
===================================================================
--- trunk/piupartslib/packagesdb.py	2009-06-21 11:48:07 UTC (rev 447)
+++ trunk/piupartslib/packagesdb.py	2009-06-25 17:17:28 UTC (rev 448)
@@ -47,43 +47,8 @@
     return headers
  
 def unique (s):
-    # taken from http://code.activestate.com/recipes/52560/ - thanks to Tim Peters
-    n = len(s)
-    if n == 0:
-      return []  
+    return list(set(seq))
 
-    u = {}
-    try:
-      for x in s:
-          u[x] = 1
-    except TypeError:
-      del u  # move on to the next method
-    else:
-      return u.keys()   
-
-    try:
-      t = list(s)
-      t.sort()
-    except TypeError:
-      del t  # move on to the next method
-    else:
-      assert n > 0
-      last = t[0]
-      lasti = i = 1
-      while i < n:
-          if t[i] != last:
-              t[lasti] = last = t[i]
-              lasti += 1
-          i += 1
-      return t[:lasti]
-
-    # Brute force is all that's left.
-    u = []
-    for x in s:
-      if x not in u:
-          u.append(x)
-    return u
-
 class Package(UserDict.UserDict):
 
     def __init__(self, headers):




More information about the Piuparts-commits mailing list