[Piuparts-commits] rev 449 - trunk/piupartslib

Holger Levsen holger at alioth.debian.org
Fri Jun 26 10:12:16 UTC 2009


Author: holger
Date: 2009-06-26 10:12:15 +0000 (Fri, 26 Jun 2009)
New Revision: 449

Modified:
   trunk/piupartslib/packagesdb.py
Log:
revert liw?\194?\180s change as it doesnt work. even with s#seq#s#

Modified: trunk/piupartslib/packagesdb.py
===================================================================
--- trunk/piupartslib/packagesdb.py	2009-06-25 17:17:28 UTC (rev 448)
+++ trunk/piupartslib/packagesdb.py	2009-06-26 10:12:15 UTC (rev 449)
@@ -47,8 +47,43 @@
     return headers
  
 def unique (s):
-    return list(set(seq))
+    # taken from http://code.activestate.com/recipes/52560/ - thanks to Tim Peters
+    n = len(s)
+    if n == 0:
+      return []  
 
+    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