Gürersan'ın değişiklikleri...

This commit is contained in:
S.Çağlar Onur
2005-09-16 06:56:36 +00:00
parent 7c745243b2
commit 1928e6b80b
+17 -40
View File
@@ -32,45 +32,15 @@ def valuesort(x, y):
return 1 return 1
class Max:
def __init__(self, title, count):
self.list = {}
self.title = title
self.count = count
def add(self, name, value):
list = {}
i = 0
for x,y in self.list.items():
if value > y:
list[name] = value
else:
list[x] = y
i += 1
if i >= self.count:
break
if i < self.count:
list[name] = value
self.list = list
def get_list(self):
items = self.list.items()
items.sort(valuesort)
return items
def html_out(self):
echo(("<h1>%s</h1><table>" % self.title) % self.count)
for x,y in self.get_list():
echo("<tr><td>%s</td><td>%s</td></tr>" % (x, y))
echo("</table>")
class Histogram: class Histogram:
def __init__(self, title): def __init__(self, title):
self.list = {} self.list = {}
self.title = title self.title = title
def add(self, name): def add(self, name, value=None):
if value:
self.list[name] = value
else:
if self.list.has_key(name): if self.list.has_key(name):
self.list[name] = self.list[name] + 1 self.list[name] = self.list[name] + 1
else: else:
@@ -81,9 +51,12 @@ class Histogram:
items.sort(valuesort) items.sort(valuesort)
return items return items
def html_out(self): def html_out(self, max=0):
echo("<h1>%s</h1><table>" % self.title) echo("<h1>%s</h1><table>" % self.title)
for name,cnt in self.get_list(): list = self.get_list()
if max != 0:
list = list[:max]
for name,cnt in list:
echo("<tr><td>%s</td><td>%s</td></tr>" % (name, cnt)) echo("<tr><td>%s</td><td>%s</td></tr>" % (name, cnt))
echo("</table>") echo("</table>")
@@ -120,8 +93,8 @@ components = Histogram(_("Components"))
dependencies = Histogram(_("Dependencies")) dependencies = Histogram(_("Dependencies"))
releases = Histogram(_("Releases")) releases = Histogram(_("Releases"))
types = Histogram(_("File types")) types = Histogram(_("File types"))
mostpatched = Max(_("Top %d most patched source"), 5) mostpatched = Histogram(_("Top five most patched source"))
longpy = Max(_("Top %d longest action.py scripts"), 5) longpy = Histogram(_("Top five longest action.py scripts"))
nr_binpaks = 0 nr_binpaks = 0
nr_patches = 0 nr_patches = 0
paknames = {} paknames = {}
@@ -171,8 +144,8 @@ echo("</head><body>")
print "<p>Toplam %d kod paketi, ve bunlardan oluşturulacak %d ikili paket var.</p>" % (len(paks), nr_binpaks) print "<p>Toplam %d kod paketi, ve bunlardan oluşturulacak %d ikili paket var.</p>" % (len(paks), nr_binpaks)
echo(u"<p>Toplam peç sayısı %d</p>" % nr_patches) echo(u"<p>Toplam peç sayısı %d</p>" % nr_patches)
mostpatched.html_out() mostpatched.html_out(5)
longpy.html_out() longpy.html_out(5)
if errors != []: if errors != []:
print "<h1>Hatalar</h1><table>" print "<h1>Hatalar</h1><table>"
@@ -192,13 +165,17 @@ types.html_out()
echo(_("<h1>Dependencies<br>")) echo(_("<h1>Dependencies<br>"))
echo(_("<small>package name with italics are not available in the repository</small></h1>")) echo(_("<small>package name with italics are not available in the repository</small></h1>"))
print "<table>" print "<table>"
notavail = 0
for name,cnt in dependencies.get_list(): for name,cnt in dependencies.get_list():
if paknames.has_key(name): if paknames.has_key(name):
print "<tr><td><b>%s</b></td><td>%d</td></tr>" % (name, cnt) print "<tr><td><b>%s</b></td><td>%d</td></tr>" % (name, cnt)
else: else:
notavail += 1
print "<tr><td><i>%s</i></td><td>%d</td></tr>" % (name, cnt) print "<tr><td><i>%s</i></td><td>%d</td></tr>" % (name, cnt)
print "</table>" print "</table>"
print "<p>%d packages are not available in repository.</p>" % notavail
hosts.html_out() hosts.html_out()
print "</body>" print "</body>"