SOURCES: rpmlist.py - last package was lost in sort_and_uniq

witekfl witekfl at pld-linux.org
Sun Oct 28 15:08:39 CET 2007


Author: witekfl                      Date: Sun Oct 28 14:08:39 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- last package was lost in sort_and_uniq

---- Files affected:
SOURCES:
   rpmlist.py (1.3 -> 1.4) 

---- Diffs:

================================================================
Index: SOURCES/rpmlist.py
diff -u SOURCES/rpmlist.py:1.3 SOURCES/rpmlist.py:1.4
--- SOURCES/rpmlist.py:1.3	Sun Oct 28 07:46:44 2007
+++ SOURCES/rpmlist.py	Sun Oct 28 15:08:34 2007
@@ -14,18 +14,19 @@
 rpm_pattern = re.compile('^(.*)-(.*)-(.*)\.(.*)$')
 poldek_pattern = re.compile('(.*);')
 
+def uniq(x):
+	global previous
+	(gr, napis, typ) = x
+	res = (napis != previous)
+	previous = napis
+	return res
+
 def sort_and_uniq():
 	"Sorts packages and remove duplicates."
-	global pakiety
+	global pakiety, previous
 	pakiety.sort(key = operator.itemgetter(1))
-	liczba = len(pakiety)
-	lista = []
-	for i in xrange(liczba - 2):
-		(pkg, napis, typ) = pakiety[i]
-		(pkg_next, napis_next, typ_next) = pakiety[i + 1]
-		if (napis != napis_next):
-			lista.append((pkg, napis, typ))
-	pakiety = lista
+	previous = ''
+	pakiety = filter(uniq, pakiety)
 
 def show_groups():
 	"Show groups."
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/rpmlist.py?r1=1.3&r2=1.4&f=u



More information about the pld-cvs-commit mailing list