[Treepkg-commits] r81 - trunk/recipes/gnupg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jun 11 11:48:57 CEST 2008


Author: bh
Date: 2008-06-11 11:48:57 +0200 (Wed, 11 Jun 2008)
New Revision: 81

Added:
   trunk/recipes/gnupg/pkits.html
Modified:
   trunk/recipes/gnupg/gnupg2.py
Log:
gnupg2 recipe: format the PKITS log as a HTML table


Modified: trunk/recipes/gnupg/gnupg2.py
===================================================================
--- trunk/recipes/gnupg/gnupg2.py	2008-06-10 15:37:22 UTC (rev 80)
+++ trunk/recipes/gnupg/gnupg2.py	2008-06-11 09:48:57 UTC (rev 81)
@@ -12,8 +12,11 @@
 import logging
 import re
 
+from genshi.template import TemplateLoader
+
 import treepkg.packager
 import treepkg.util
+import treepkg.report
 
 import base
 base.define_gnupg_packager("gnupg2")
@@ -62,17 +65,24 @@
             logging.info("Could not find PKITS LOG in %s", self.logfile)
             return
         treepkg.util.ensure_directory(os.path.dirname(self.pkits_log))
-        outfile = open(self.pkits_log, "w")
-        outfile.writelines(testlog)
-        outfile.close()
+        treepkg.util.writefile(self.pkits_log,
+                               self.htmlize_pkits_log(testlog))
 
+    def htmlize_pkits_log(self, raw_lines):
+        loader = TemplateLoader([os.path.dirname(__file__)])
+        template = loader.load("pkits.html")
+        pkits = treepkg.report.struct(revision=self.parent.revision,
+                                      lines=raw_lines)
+        stream = template.generate(pkits=pkits)
+        return stream.render('html')
 
+
 class RevisionPackager(treepkg.packager.RevisionPackager):
 
     source_packager_cls = SourcePackager
     binary_packager_cls = BinaryPackager
 
-    pkits_log = treepkg.packager._filenameproperty("pkits_log.txt",
+    pkits_log = treepkg.packager._filenameproperty("pkits_log.html",
                                                    dir_attr="log_dir")
 
     def list_log_files(self):

Added: trunk/recipes/gnupg/pkits.html
===================================================================
--- trunk/recipes/gnupg/pkits.html	2008-06-10 15:37:22 UTC (rev 80)
+++ trunk/recipes/gnupg/pkits.html	2008-06-11 09:48:57 UTC (rev 81)
@@ -0,0 +1,37 @@
+<html xmlns:py="http://genshi.edgewall.org/">
+  <head>
+    <title>PKITS Log for GnuPG2 rev. ${pkits.revision}</title>
+    <style type="text/css">
+      .statustable { background:#F4F4F4; }
+      .statustablehead { background:#E0E0E0; }
+      .statusheading { font-weight:bold; }
+      .PASS { background:#C0FFC0; }
+      .SKIP { background:#FFFFC0; }
+      .FAIL { background:#FFC0C0; }
+      .UNRESOLVED { background:#D0D0D0 }
+      .unknown { background:#FFFFFF }
+      tr { background:#FFFFFF; }
+      td { padding:5px; }
+    </style>
+  </head>
+  <body>
+    <H1>PKITS Log for GnuPG2 rev. ${pkits.revision}</H1>
+    <table class="statustable">
+      <tr>
+	<th class="statustablehead">Test ID</th>
+	<th class="statustablehead">Status</th>
+	<th class="statustablehead">Details</th>
+      </tr>
+      <py:for each="line in pkits.lines">
+	<py:with vars="testid, status, details = line.split(None, 2)">
+	  <tr class="${status in ['PASS', 'SKIP', 'FAIL', 'UNRESOLVED']
+                       and status or 'unknown'}">
+	    <td>${testid}</td>
+	    <td>${status}</td>
+	    <td>${details}</td>
+	  </tr>
+	</py:with>
+      </py:for>
+    </table>
+  </body>
+</html>



More information about the Treepkg-commits mailing list