[csw-devel] SF.net SVN: gar:[10955] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Sep 13 16:05:15 CEST 2010
Revision: 10955
http://gar.svn.sourceforge.net/gar/?rev=10955&view=rev
Author: wahwah
Date: 2010-09-13 14:05:15 +0000 (Mon, 13 Sep 2010)
Log Message:
-----------
mGAR v2: Added error tags and overrides to the HTML report.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/pkg-review-template.html
csw/mgar/gar/v2/lib/python/pkgdb.py
Modified: csw/mgar/gar/v2/lib/python/pkg-review-template.html
===================================================================
--- csw/mgar/gar/v2/lib/python/pkg-review-template.html 2010-09-13 13:54:12 UTC (rev 10954)
+++ csw/mgar/gar/v2/lib/python/pkg-review-template.html 2010-09-13 14:05:15 UTC (rev 10955)
@@ -50,6 +50,18 @@
margin: 0px;
padding: 2px;
}
+ul.error_tags li {
+ list-style: none;
+ background-color: #FDD;
+ padding: 0px;
+ margin: 0px;
+}
+ul.overrides li {
+ list-style: none;
+ background-color: #FFD;
+ padding: 0px;
+ margin: 0px;
+}
</style>
</head>
<body>
@@ -75,6 +87,8 @@
</h2>
<ul>
<li><a href="#${pkg.basic_stats.md5_sum}-pkginfo">pkginfo</a></li>
+ <li><a href="#${pkg.basic_stats.md5_sum}-error_tags">error tags</a></li>
+ <li><a href="#${pkg.basic_stats.md5_sum}-overrides">overrides</a></li>
<li><a href="#${pkg.basic_stats.md5_sum}-binaries_dump_info">binaries_dump_info</a></li>
<li><a href="#${pkg.basic_stats.md5_sum}-depends">depends</a></li>
<li><a href="#${pkg.basic_stats.md5_sum}-files_metadata">files_metadata</a></li>
@@ -192,6 +206,49 @@
</tr>
#end for
</table>
+
+ <h2>
+ <a name="${pkg.basic_stats.md5_sum}-error_tags">
+ Error tags
+ </a>
+ </h2>
+#if $pkg.error_tags
+ <ul class="error_tags">
+#for etag in $pkg.error_tags
+ <li>
+ <code>
+ $etag.pkgname
+ $etag.tag_name
+ $etag.tag_info
+ </code>
+ </li>
+#end for
+ </ul>
+#else
+ <p>No error tags.</p>
+#end if
+
+ <h2>
+ <a name="${pkg.basic_stats.md5_sum}-overrides">
+ Overrides
+ </a>
+ </h2>
+#if $pkg.overrides
+ <ul class="overrides">
+#for override in $pkg.overrides
+ <li>
+ <code>
+ $override.pkgname
+ $override.tag_name
+ $override.tag_info
+ </code>
+ </li>
+#end for
+ </ul>
+#else
+ <p>No overrides.</p>
+#end if
+
#if $pkg.binaries_dump_info
<h2>
<a name="${pkg.basic_stats.md5_sum}-binaries_dump_info">
Modified: csw/mgar/gar/v2/lib/python/pkgdb.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgdb.py 2010-09-13 13:54:12 UTC (rev 10954)
+++ csw/mgar/gar/v2/lib/python/pkgdb.py 2010-09-13 14:05:15 UTC (rev 10955)
@@ -35,7 +35,62 @@
stats_version: $stats_version
"""
+DEFAULT_TEMPLATE_FILENAME = "../lib/python/pkg-review-template.html"
+
+class HtmlGenerator(object):
+
+ def __init__(self, md5_sums, template=None):
+ self.md5_sums = md5_sums
+ self.template = template
+
+ def GetErrorTagsResult(self, srv4):
+ res = m.CheckpkgErrorTag.select(
+ m.CheckpkgErrorTag.q.srv4_file==srv4)
+ return res
+
+ def GetOverrideResult(self, srv4):
+ res = m.CheckpkgOverride.select(
+ m.CheckpkgOverride.q.srv4_file==srv4)
+ return res
+
+ def GenerateHtml(self):
+ pkgstats = []
+ # Add error tags
+ for md5_sum in self.md5_sums:
+ srv4 = GetPkg(md5_sum)
+ data = cPickle.loads(str(srv4.data))
+ if "OPENCSW_REPOSITORY" in data["pkginfo"]:
+ build_src = data["pkginfo"]["OPENCSW_REPOSITORY"]
+ build_src_url_svn = re.sub(r'([^@]*).*', r'\1/Makefile', build_src)
+ build_src_url_trac = re.sub(
+ r'https://gar.svn.(sf|sourceforge).net/svnroot/gar/([^@]+)@(.*)',
+ r'http://sourceforge.net/apps/trac/gar/browser/\2/Makefile?rev=\3',
+ build_src)
+ else:
+ build_src = None
+ build_src_url_svn = None
+ build_src_url_trac = None
+ data["build_src"] = build_src
+ data["build_src_url_svn"] = build_src_url_svn
+ data["build_src_url_trac"] = build_src_url_trac
+ data["error_tags"] = list(self.GetErrorTagsResult(srv4))
+ data["overrides"] = list(self.GetOverrideResult(srv4))
+ pkgstats.append(data)
+ # This assumes the program is run as "bin/pkgdb", and not "lib/python/pkgdb.py".
+ if not self.template:
+ tmpl_filename = os.path.join(os.path.split(__file__)[0],
+ DEFAULT_TEMPLATE_FILENAME)
+ else:
+ tmpl_filename = self.template
+ tmpl_str = open(tmpl_filename, "r").read()
+ t = Template(tmpl_str, searchList=[{
+ "pkgstats": pkgstats,
+ "hachoir_machines": package_checks.HACHOIR_MACHINES,
+ }])
+ return unicode(t)
+
+
def GetPkg(some_id):
logging.debug("Selecting from db: %s", repr(some_id))
res = m.Srv4FileStats.select(
@@ -99,41 +154,8 @@
t = Template(SHOW_PKG_TMPL, searchList=[srv4])
sys.stdout.write(unicode(t))
if command == 'gen-html':
- pkgstats = []
- # Add error tags
- for md5_sum in md5_sums:
- srv4 = GetPkg(md5_sum)
- data = cPickle.loads(str(srv4.data))
- if "OPENCSW_REPOSITORY" in data["pkginfo"]:
- build_src = data["pkginfo"]["OPENCSW_REPOSITORY"]
- build_src_url_svn = re.sub(r'([^@]*).*', r'\1/Makefile', build_src)
- build_src_url_trac = re.sub(
- r'https://gar.svn.(sf|sourceforge).net/svnroot/gar/([^@]+)@(.*)',
- r'http://sourceforge.net/apps/trac/gar/browser/\2/Makefile?rev=\3',
- build_src)
- else:
- build_src = None
- build_src_url_svn = None
- build_src_url_trac = None
- data["build_src"] = build_src
- data["build_src_url_svn"] = build_src_url_svn
- data["build_src_url_trac"] = build_src_url_trac
- pkgstats.append(data)
- # This assumes the program is run as "bin/pkgdb", and not "lib/python/pkgdb.py".
- if not options.pkg_review_template:
- tmpl_filename = os.path.join(os.path.split(__file__)[0],
- "..",
- "lib",
- "python",
- "pkg-review-template.html")
- else:
- tmpl_filename = options.pkg_review_template
- tmpl_str = open(tmpl_filename, "r").read()
- t = Template(tmpl_str, searchList=[{
- "pkgstats": pkgstats,
- "hachoir_machines": package_checks.HACHOIR_MACHINES,
- }])
- sys.stdout.write(unicode(t))
+ g = HtmlGenerator(md5_sums)
+ sys.stdout.write(g.GenerateHtml())
if __name__ == '__main__':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list