kategorileri de listeleyelim. komponentleri düzgün toplayalım.

This commit is contained in:
Gürer Özen
2005-08-17 13:38:36 +00:00
parent 394f64e180
commit 4d8985f8b0
+55 -31
View File
@@ -23,6 +23,48 @@ import pisi.uri
def echo(string): def echo(string):
print string.encode("utf8") print string.encode("utf8")
def valuesort(x, y):
if x[1] > y[1]:
return -1
elif x[1] == y[1]:
return 0
else:
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 = {}
@@ -34,17 +76,9 @@ class Histogram:
else: else:
self.list[name] = 1 self.list[name] = 1
def _sortfunc(self, x, y):
if x[1] > y[1]:
return -1
elif x[1] == y[1]:
return 0
else:
return 1
def get_list(self): def get_list(self):
items = self.list.items() items = self.list.items()
items.sort(self._sortfunc) items.sort(valuesort)
return items return items
def html_out(self): def html_out(self):
@@ -81,15 +115,14 @@ def add_deps(deps, spec):
hosts = Histogram(_("Source hosts")) hosts = Histogram(_("Source hosts"))
people = Histogram(_("Packagers")) people = Histogram(_("Packagers"))
licenses = Histogram(_("Licenses")) licenses = Histogram(_("Licenses"))
categories = Histogram(_("Categories"))
components = Histogram(_("Components")) components = Histogram(_("Components"))
dependencies = Histogram(_("Dependencies")) dependencies = Histogram(_("Dependencies"))
types = Histogram(_("File types")) types = Histogram(_("File types"))
mostp_name = None mostpatched = Max(_("Top %d most patched source"), 5)
mostp_count = 0 longpy = Max(_("Top %d longest action.py scripts"), 5)
nr_binpaks = 0 nr_binpaks = 0
nr_patches = 0 nr_patches = 0
maxpy_lines = 0
maxpy_name = None
paknames = {} paknames = {}
errors = [] errors = []
@@ -102,35 +135,27 @@ for pak in paks:
except Exception, inst: except Exception, inst:
errors.append([pak, str(inst)]) errors.append([pak, str(inst)])
continue continue
errs = spec.has_errors()
if errs:
for e in errs:
errors.append([pak, e])
continue
try: try:
f = file(os.path.join(pak, "actions.py")) f = file(os.path.join(pak, "actions.py"))
L = len(f.readlines()) L = len(f.readlines())
if L > maxpy_lines: longpy.add(spec.source.name, L)
maxpy_lines = L
maxpy_name = spec.source.name
f.close() f.close()
except: except:
pass pass
nr_binpaks += len(spec.packages) nr_binpaks += len(spec.packages)
nr_patches += len(spec.source.patches) nr_patches += len(spec.source.patches)
mostpatched.add(spec.source.name, len(spec.source.patches))
for p in spec.packages: for p in spec.packages:
if p.partof:
components.add(p.partof)
for x in p.isa:
categories.add(x)
for x in p.paths: for x in p.paths:
types.add(x.fileType) types.add(x.fileType)
paknames[spec.source.name] = 1 paknames[spec.source.name] = 1
add_deps(dependencies, spec) add_deps(dependencies, spec)
if len(spec.source.patches) > mostp_count:
mostp_count = len(spec.source.patches)
mostp_name = spec.source.name
name = spec.source.packager.name name = spec.source.packager.name
lices = spec.source.license lices = spec.source.license
partof = spec.source.partof
if partof:
components.add(partof)
people.add(name) people.add(name)
for lice in lices: for lice in lices:
licenses.add(lice) licenses.add(lice)
@@ -143,11 +168,9 @@ 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)
if mostp_count > 0:
echo(u"<p>En çok peçlenen yazılım %d peçle %s!</p>" % (mostp_count, mostp_name))
if maxpy_lines > 0: mostpatched.html_out()
echo(u"<p>En uzun actions.py betiğine sahip yazılım %d satırla %s!</p>" % (maxpy_lines, maxpy_name)) longpy.html_out()
if errors != []: if errors != []:
print "<h1>Hatalar</h1><table>" print "<h1>Hatalar</h1><table>"
@@ -158,6 +181,7 @@ else:
print "<p>Hata yok, tebrikler!</p>" print "<p>Hata yok, tebrikler!</p>"
components.html_out() components.html_out()
categories.html_out()
people.html_out() people.html_out()
licenses.html_out() licenses.html_out()
types.html_out() types.html_out()