restructuring #1
This commit is contained in:
+98
-130
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005, TUBITAK/UEKAE
|
# Copyright (C) 2005-2007, TUBITAK/UEKAE
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
# This program is free software; you can redistribute it and/or modify it under
|
||||||
# the terms of the GNU General Public License as published by the Free
|
# the terms of the GNU General Public License as published by the Free
|
||||||
@@ -29,6 +29,42 @@ import pisi.metadata
|
|||||||
import pisi.files
|
import pisi.files
|
||||||
from pisi.cli import printu
|
from pisi.cli import printu
|
||||||
|
|
||||||
|
# Main HTML template
|
||||||
|
|
||||||
|
html_header = """
|
||||||
|
<html><head>
|
||||||
|
<title>%(title)s</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<link href="http://www.pardus.org.tr/styles/stil.css" rel="stylesheet" type="text/css">
|
||||||
|
</head><body>
|
||||||
|
<div id='header-bugzilla'>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='statmenu'>
|
||||||
|
<a href='index.html'>Genel Bilgiler</a>
|
||||||
|
| <a href='sources.html'>Kaynak Paketler</a>
|
||||||
|
| <a href='binaries.html'>İkili Paketler</a>
|
||||||
|
| <a href='packagers.html'>Paketçiler</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h1 align='center'>%(title)s</h1>
|
||||||
|
|
||||||
|
<div id='content'>
|
||||||
|
%(content)s
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body></html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# default html templates
|
# default html templates
|
||||||
|
|
||||||
def_table_html = u"""
|
def_table_html = u"""
|
||||||
@@ -44,47 +80,6 @@ def_repo_sizes_html = u"""
|
|||||||
</table></tbody>
|
</table></tbody>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def_repo_html = u"""
|
|
||||||
<html><head>
|
|
||||||
<title>Depo istatistikleri</title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<link href="http://www.pardus.org.tr/styles/stil.css" rel="stylesheet" type="text/css">
|
|
||||||
</head><body>
|
|
||||||
<div id="header-bugzilla">
|
|
||||||
</div>
|
|
||||||
<div id="packets">
|
|
||||||
<p>
|
|
||||||
Depoda toplam %(nr_source)d
|
|
||||||
<a href="./sources.html">kaynak paket</a>, ve bu paketlerden oluşturulacak
|
|
||||||
%(nr_packages)d ikili paket bulunmaktadır. Toplam %(nr_patches)d yama mevcuttur.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%(errors)s
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>En fazla yamalanmış 5 kaynak paket:</h3><p><table><tbody>
|
|
||||||
%(most_patched)s
|
|
||||||
</tbody></table></p>
|
|
||||||
|
|
||||||
<h3>En uzun actions.py betikli 5 kaynak paket:</h3><p><table><tbody>
|
|
||||||
%(longpy)s
|
|
||||||
</tbody></table></p>
|
|
||||||
|
|
||||||
<h3>Eksik ikili paketler</h3><p><table><tbody>
|
|
||||||
%(missing)s
|
|
||||||
</tbody></table></p>
|
|
||||||
|
|
||||||
%(sizes)s
|
|
||||||
|
|
||||||
<h3>Paketçiler:</h3><p><table><tbody>
|
|
||||||
%(packagers)s
|
|
||||||
</tbody></table></p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body></html>
|
|
||||||
"""
|
|
||||||
|
|
||||||
def_packager_html = u"""
|
def_packager_html = u"""
|
||||||
<html><head>
|
<html><head>
|
||||||
<title>Paketçi %(name)s</title>
|
<title>Paketçi %(name)s</title>
|
||||||
@@ -240,20 +235,6 @@ def svn_uri(path):
|
|||||||
return uri
|
return uri
|
||||||
|
|
||||||
|
|
||||||
# FIXME: This check should be in specfile
|
|
||||||
valid_filetypes = [
|
|
||||||
"executable",
|
|
||||||
"library",
|
|
||||||
"data",
|
|
||||||
"config",
|
|
||||||
"doc",
|
|
||||||
"man",
|
|
||||||
"info",
|
|
||||||
"localedata",
|
|
||||||
"header",
|
|
||||||
"all"
|
|
||||||
]
|
|
||||||
|
|
||||||
def valuesort(x, y):
|
def valuesort(x, y):
|
||||||
if x[1] > y[1]:
|
if x[1] > y[1]:
|
||||||
return -1
|
return -1
|
||||||
@@ -286,6 +267,27 @@ def template_write(filename, tmpl_name, dict):
|
|||||||
f.write(template_get(tmpl_name) % dict)
|
f.write(template_get(tmpl_name) % dict)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def write_html(filename, title, content):
|
||||||
|
f = codecs.open(filename, "w", "utf-8")
|
||||||
|
dict = {
|
||||||
|
"title": title,
|
||||||
|
"content": content,
|
||||||
|
}
|
||||||
|
f.write(html_header % dict)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def make_table(elements):
|
||||||
|
def make_row(element):
|
||||||
|
return "<td>%s" % "<td>".join(map(str, element))
|
||||||
|
|
||||||
|
html = """
|
||||||
|
<table><tbody>
|
||||||
|
<tr>%s
|
||||||
|
</tbody></table>
|
||||||
|
""" % "<tr>".join(map(make_row, elements))
|
||||||
|
|
||||||
|
return html
|
||||||
|
|
||||||
def template_table(tmpl_name, list):
|
def template_table(tmpl_name, list):
|
||||||
tmpl = template_get(tmpl_name)
|
tmpl = template_get(tmpl_name)
|
||||||
data = ""
|
data = ""
|
||||||
@@ -361,11 +363,6 @@ class Package:
|
|||||||
errors.append(_("Duplicate binary packages:\n%s\n%s\n") % (
|
errors.append(_("Duplicate binary packages:\n%s\n%s\n") % (
|
||||||
source.name, packages[name].source.name))
|
source.name, packages[name].source.name))
|
||||||
return
|
return
|
||||||
for p in pakspec.files:
|
|
||||||
if p.fileType not in valid_filetypes:
|
|
||||||
e = _("Unknown file type '%s' in package '%s'") % (
|
|
||||||
p.fileType, source.name)
|
|
||||||
errors.append(e)
|
|
||||||
packages[name] = self
|
packages[name] = self
|
||||||
self.name = name
|
self.name = name
|
||||||
self.source = source
|
self.source = source
|
||||||
@@ -429,22 +426,6 @@ class Source:
|
|||||||
self.uri = svn_uri(path)
|
self.uri = svn_uri(path)
|
||||||
for p in spec.packages:
|
for p in spec.packages:
|
||||||
Package(self, p)
|
Package(self, p)
|
||||||
self.checkRelease()
|
|
||||||
|
|
||||||
def validDate(self, date):
|
|
||||||
# yyyy-mm-dd
|
|
||||||
err = 0
|
|
||||||
if len(date) != 10:
|
|
||||||
err = 1
|
|
||||||
if date[4] != '-' or date[7] != '-':
|
|
||||||
err = 1
|
|
||||||
if err:
|
|
||||||
e = _("Source package '%s' has wrong date format '%s'") % (self.name, date)
|
|
||||||
errors.append(e)
|
|
||||||
# more checks can be added, i.e. valid day month ranges, etc
|
|
||||||
|
|
||||||
def checkRelease(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def report_html(self):
|
def report_html(self):
|
||||||
source = self.spec.source
|
source = self.spec.source
|
||||||
@@ -595,45 +576,46 @@ class Repository:
|
|||||||
self.processPisi(os.path.join(root, fn))
|
self.processPisi(os.path.join(root, fn))
|
||||||
|
|
||||||
def report_html(self):
|
def report_html(self):
|
||||||
miss = map(lambda x: "<tr><td><a href='./binary/%s.html'>%s</a></td></tr>" % (x, x), missing.keys())
|
table = (
|
||||||
upeople = []
|
("Kaynak paket sayısı", self.nr_sources),
|
||||||
for p in self.people.get_list():
|
("İkili paket sayısı", self.nr_packages),
|
||||||
upeople.append(("<a href='./packager/%s.html'>%s</a>" % (p[0], p[0]), p[1]))
|
("Yama sayısı", self.nr_patches),
|
||||||
if errors:
|
("Paketçi sayısı", len(self.people.list)),
|
||||||
e = "<br>".join(errors)
|
)
|
||||||
else:
|
html = make_table(table)
|
||||||
e = ""
|
|
||||||
upatch = []
|
html += """
|
||||||
for p in self.mostpatched.get_list(5):
|
<div class='statstat'>
|
||||||
upatch.append(("<a href='./source/%s.html'>%s</a>" % (p[0], p[0]), p[1]))
|
<h3>En fazla yamalanmış beş kaynak paket:</h3><p>
|
||||||
ulongpy = []
|
%s
|
||||||
for p in self.longpy.get_list(5):
|
</p></div>
|
||||||
ulongpy.append(("<a href='./source/%s.html'>%s</a>" % (p[0], p[0]), p[1]))
|
""" % make_table(self.mostpatched.get_list(5))
|
||||||
if self.total_installed_size:
|
|
||||||
items = self.installed_sizes.items()
|
html += """
|
||||||
items.sort(valuesort)
|
<div class='statstat'>
|
||||||
elts = "".join(map(lambda x: "<tr><td>%s</td><td>%d</td></tr>" % (x[0], x[1]), items))
|
<h3>En uzun inşa betikli beş kaynak paket:</h3><p>
|
||||||
sizes = template_get("repo_sizes") % { "total": self.total_installed_size, "sizes": elts }
|
%s
|
||||||
else:
|
</p></div>
|
||||||
sizes = ""
|
""" % make_table(self.longpy.get_list(5))
|
||||||
dict = {
|
|
||||||
"nr_source": self.nr_sources,
|
write_html("paksite/index.html", "Depo İstatistikleri", html)
|
||||||
"nr_packages": self.nr_packages,
|
|
||||||
"nr_patches": self.nr_patches,
|
people = self.people.get_list()
|
||||||
"most_patched": template_table("table", upatch),
|
people = map(lambda x: ("<a href='./packager/%s.html'>%s</a>" % (x[0], x[0]), x[1]), people)
|
||||||
"longpy": template_table("table", ulongpy),
|
write_html("paksite/packagers.html", "Paketçiler (paket sayısına göre)", make_table(people))
|
||||||
"packagers": template_table("table", upeople),
|
|
||||||
"missing": "\n".join(miss),
|
people.sort(key=lambda x: x[0])
|
||||||
"sizes": sizes,
|
write_html("paksite/packagers_by_name.html", "Paketçiler (isme göre)", make_table(people))
|
||||||
"errors": e
|
|
||||||
}
|
srclist = map(lambda x: (x.name, x.spec.getSourceVersion(), x.spec.source.summary), sources.values())
|
||||||
template_write("paksite/index.html", "repo", dict)
|
srclist.sort(key=lambda x: x[0])
|
||||||
srclist = map(lambda x: "<a href='./source/%s.html'>%s</a>" % (x, x), sources)
|
html = make_table(srclist)
|
||||||
srclist.sort()
|
write_html("paksite/sources.html", "Kaynak Paketler", html)
|
||||||
dict = {
|
|
||||||
"source_list": "<br>".join(srclist)
|
binlist = map(lambda x: (x.name, x.source.spec.getSourceVersion(), x.source.spec.source.summary), packages.values())
|
||||||
}
|
binlist.sort(key=lambda x: x[0])
|
||||||
template_write("paksite/sources.html", "sources", dict)
|
html = make_table(binlist)
|
||||||
|
write_html("paksite/binaries.html", "İkili Paketler", html)
|
||||||
|
|
||||||
|
|
||||||
# command line driver
|
# command line driver
|
||||||
@@ -668,20 +650,6 @@ if __name__ == "__main__":
|
|||||||
printu(_("Scanning binary packages...\n"))
|
printu(_("Scanning binary packages...\n"))
|
||||||
repo.scan_bins(args[1])
|
repo.scan_bins(args[1])
|
||||||
|
|
||||||
if errors:
|
|
||||||
printu("***\n")
|
|
||||||
printu(_("Encountered %d errors! Fix them immediately!\n") % len(errors))
|
|
||||||
for e in errors:
|
|
||||||
printu(e)
|
|
||||||
printu("\n")
|
|
||||||
printu("\n")
|
|
||||||
printu("***\n")
|
|
||||||
|
|
||||||
if missing:
|
|
||||||
printu(_("These dependencies are not available in repository:\n"))
|
|
||||||
for m in missing.keys():
|
|
||||||
printu(" %s\n" % m)
|
|
||||||
|
|
||||||
if do_web:
|
if do_web:
|
||||||
if not os.path.exists("paksite/packager"):
|
if not os.path.exists("paksite/packager"):
|
||||||
os.makedirs("paksite/packager")
|
os.makedirs("paksite/packager")
|
||||||
|
|||||||
Reference in New Issue
Block a user