SOURCES: rpmlist.py - handle case when there are no poldek package...

witekfl witekfl at pld-linux.org
Sun Oct 28 07:46:49 CET 2007


Author: witekfl                      Date: Sun Oct 28 06:46:49 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- handle case when there are no poldek packages
- renamed Pyldek to Poldek_package
- simplification (no need for compare function)

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

---- Diffs:

================================================================
Index: SOURCES/rpmlist.py
diff -u SOURCES/rpmlist.py:1.2 SOURCES/rpmlist.py:1.3
--- SOURCES/rpmlist.py:1.2	Fri Oct 26 19:03:48 2007
+++ SOURCES/rpmlist.py	Sun Oct 28 07:46:44 2007
@@ -2,7 +2,7 @@
 # vim:fileencoding=UTF-8
 # $Revision$, $Date$
 
-import BaseHTTPServer, cgi, datetime, locale, os, poldek, re, rpm, sys, urllib
+import BaseHTTPServer, cgi, datetime, locale, operator, os, poldek, re, rpm, sys, urllib
 
 TYP_RPM = 0
 TYP_POLDEK = 1
@@ -14,23 +14,10 @@
 rpm_pattern = re.compile('^(.*)-(.*)-(.*)\.(.*)$')
 poldek_pattern = re.compile('(.*);')
 
-def compare(a, b):
-	"Compare two packages by name."
-	global TYP_RPM
-	(pak1, napis1, typ1) = a
-	(pak2, napis2, typ2) = b
-	w = cmp(napis1, napis2)
-	if w == 0:
-		if typ1 == TYP_RPM:
-			return 1
-		else:
-			return -1
-	return w
-
 def sort_and_uniq():
 	"Sorts packages and remove duplicates."
 	global pakiety
-	pakiety.sort(compare)
+	pakiety.sort(key = operator.itemgetter(1))
 	liczba = len(pakiety)
 	lista = []
 	for i in xrange(liczba - 2):
@@ -169,7 +156,7 @@
 			return html
 		return False
 
-class Pyldek:
+class Poldek_package:
 	"Contains methods related to poldek's packages."
 	def __init__(self):
 		ctx = poldek.poldek_ctx()
@@ -193,6 +180,9 @@
 		packages = self.return_packages()
 		for pkg in packages:
 			gr = pkg.group
+			# case when there is no poldek's package
+			if not gr:
+				break
 			napis = "%s-%s-%s.%s" % (pkg.name, pkg.ver, pkg.rel, pkg.arch())
 			if grupy.has_key(gr):
 				grupy[gr] += 1
@@ -309,7 +299,7 @@
 	content_type = 'text/html; charset=%s' % locale.nl_langinfo(locale.CODESET)
 	pak = RPM_package()
 	poldek.lib_init()
-	pyl = Pyldek()
+	pyl = Poldek_package()
 	load_packages()
 
 	if len(sys.argv) > 1:
================================================================

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



More information about the pld-cvs-commit mailing list