# HG changeset patch # User Bernhard Herzog # Date 1212662170 0 # Node ID 123e9a5f31fafa131dc5c0673630939f9e08eba6 # Parent dd54ef8a9244d38ce1a57faa057a4428e34ed215 Rework treepkg/report.py to prepare for other report types. Adapt reportstatus.py and web-status.html. diff -r dd54ef8a9244 -r 123e9a5f31fa bin/reportstatus.py --- 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 # @@ -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) diff -r dd54ef8a9244 -r 123e9a5f31fa treepkg/report.py --- 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 # @@ -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())) diff -r dd54ef8a9244 -r 123e9a5f31fa treepkg/web-status.html --- 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 @@ - - + + - + @@ -32,9 +32,10 @@ ${col.status.desc}
Start: ${col.status.start}
Stop: ${col.status.stop}
- - build log - + + ${title} +
+
Revision${col[1]}${track.name}
${row[0]}