changeset 145:123e9a5f31fa

Rework treepkg/report.py to prepare for other report types. Adapt reportstatus.py and web-status.html.
author Bernhard Herzog <bh@intevation.de>
date Thu, 05 Jun 2008 10:36:10 +0000
parents dd54ef8a9244
children 1766e2ee9457
files bin/reportstatus.py treepkg/report.py treepkg/web-status.html
diffstat 3 files changed, 41 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/bin/reportstatus.py	Mon Jun 02 17:44:19 2008 +0000
+++ b/bin/reportstatus.py	Thu Jun 05 10:36:10 2008 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/python2.4
-# Copyright (C) 2007 by Intevation GmbH
+# Copyright (C) 2007, 2008 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
 #
@@ -22,7 +22,7 @@
 
 def report_text(group):
     report = prepare_report(group)
-    for revno, row in report.revisions:
+    for revno, row in report.revisions.sorted_by_revision():
         for col in row:
             if col:
                 print "%s %s: %s" % (col.name, revno, col.status.desc)
--- a/treepkg/report.py	Mon Jun 02 17:44:19 2008 +0000
+++ b/treepkg/report.py	Thu Jun 05 10:36:10 2008 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 by Intevation GmbH
+# Copyright (C) 2007, 2008 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
 #
@@ -7,6 +7,8 @@
 
 """Support for status reports"""
 
+import os
+from operator import attrgetter
 import datetime
 
 from packager import create_package_track, PackagerGroup
@@ -63,27 +65,34 @@
                   stop=format_time(status.stop),
                   cls=status_class(status.status))
 
+class Revisions(object):
+
+    def __init__(self, tracks):
+        self.tracks = sorted(tracks, key=attrgetter("name"))
+
+    def sorted_by_revision(self):
+        revisions = {}
+        num_columns = len(self.tracks)
+        for column, track in enumerate(self.tracks):
+            for revision in track.get_revisions():
+                row = revisions.setdefault(revision.revision,
+                                           [None] * num_columns)
+                log_files = [(title, os.path.basename(filename))
+                              for title, filename in revision.list_log_files()]
+                row[column] = struct(revno=revision.revision,
+                                     revision=revision,
+                                     column=column,
+                                     name=track.name,
+                                     log_files=log_files,
+                                     status=prepare_status(revision.status))
+
+        # convert the revisions dict into a sorted list of (revno, row)
+        # pairs
+        revisions = revisions.items()
+        revisions.sort()
+        revisions.reverse()
+        return revisions
+
 def prepare_report(group):
-    revisions = {}
-    columns = []
-    tracks = group.get_package_tracks()
-    num_columns = len(tracks)
-    for column, track in enumerate(tracks):
-        columns.append((column, track.name))
-        for revision in track.get_revisions():
-            row = revisions.setdefault(revision.revision, [None] * num_columns)
-            row[column] = struct(revno=revision.revision,
-                                 revision=revision,
-                                 column=column,
-                                 name=track.name,
-                                 status=prepare_status(revision.status))
-
-    # convert the revisions dict into a sorted list of (revno, row)
-    # pairs
-    revisions = revisions.items()
-    revisions.sort()
-    revisions.reverse()
-
-    return struct(columns=columns,
-                  revisions=revisions,
+    return struct(revisions=Revisions(group.get_package_tracks()),
                   date=format_time(datetime.datetime.utcnow()))
--- a/treepkg/web-status.html	Mon Jun 02 17:44:19 2008 +0000
+++ b/treepkg/web-status.html	Thu Jun 05 10:36:10 2008 +0000
@@ -17,12 +17,12 @@
     <table class="statustable">
       <tr>
 	<th class="statustablehead">Revision</th>
-	<py:for each="col in report.columns">
-	  <th class="statustablehead">${col[1]}</th>
+	<py:for each="track in report.revisions.tracks">
+	  <th class="statustablehead">${track.name}</th>
 	</py:for>
       </tr>
 
-      <py:for each="row in report.revisions">
+      <py:for each="row in report.revisions.sorted_by_revision">
 	<tr>
 	  <td>${row[0]}</td>
 	  <py:for each="col in row[1]">
@@ -32,9 +32,10 @@
 		  <span class="statusheading">${col.status.desc}</span><br/>
 		  Start: ${col.status.start}<br/>
 		  Stop: ${col.status.stop}<br/>
-		  <py:if test="col.revision.has_build_log">
-		    <a href="${col.name}/${col.revno}/build_log.txt">build log</a>
-		  </py:if>
+		  <py:for each="title, basename in col.log_files">
+		    <a href="${col.name}/${col.revno}/${basename}">${title}</a>
+		    <br/>
+		  </py:for>
 		</td>
 	      </py:when>
 	      <py:otherwise>
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)