From 2fa3b3ba7b12fdce746b09b1dcd110e42a4459cf Mon Sep 17 00:00:00 2001 From: Marcus Lindblom Date: Mon, 5 Apr 2010 14:34:50 +0200 Subject: [PATCH] Replace Change's html_dict() with asDict() (see #704) --- buildbot/broken_test/runs/test_status.py | 2 +- buildbot/changes/changes.py | 27 ++++++------------------ buildbot/status/web/changes.py | 2 +- buildbot/status/web/templates/build.html | 2 +- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/buildbot/broken_test/runs/test_status.py b/buildbot/broken_test/runs/test_status.py index 8debeb38ffe..dfe00da60e3 100644 --- a/buildbot/broken_test/runs/test_status.py +++ b/buildbot/broken_test/runs/test_status.py @@ -174,7 +174,7 @@ def customHTMLMailMessage(attrs): attrs['result'].title())) text.append("

Recent Changes:

") for c in attrs['changes']: - text.append(template.module.change(**c.html_dict())) + text.append(template.module.change(c.asDict())) name, url, lines, status = attrs['logs'][-1] text.append("

Last %d lines of '%s':

" % (logLines, name)) diff --git a/buildbot/changes/changes.py b/buildbot/changes/changes.py index 5fe1f6df775..e95ec4a9e21 100644 --- a/buildbot/changes/changes.py +++ b/buildbot/changes/changes.py @@ -89,8 +89,10 @@ def asText(self): data += "Properties: \n%s\n\n" % self.getProperties() return data - def html_dict(self): + def asDict(self): '''returns a dictonary with suitable info for html/mail rendering''' + result = {} + files = [] for file in self.files: link = filter(lambda s: s.find(file) != -1, self.links) @@ -101,24 +103,7 @@ def html_dict(self): files.append(dict(url=url, name=file)) files = sorted(files, cmp=lambda a,b: a['name'] < b['name']) - - kwargs = { 'who' : self.who, - 'at' : self.getTime(), - 'files' : files, - 'rev' : self.revision, - 'revlink' : getattr(self, 'revlink', None), - 'branch' : self.branch, - 'comments' : self.comments, - 'properties': self.properties.asList(), - 'number' : self.number, - 'repository': getattr(self, 'repository', None), - 'project' : getattr(self, 'project', None) - } - - return kwargs - - def asDict(self): - result = {} + # Constant result['number'] = self.number result['branch'] = self.branch @@ -126,8 +111,10 @@ def asDict(self): result['who'] = self.getShortAuthor() result['comments'] = self.comments result['revision'] = self.revision + result['rev'] = self.revision result['when'] = self.when - result['files'] = self.files + result['at'] = self.getTime() + result['files'] = files result['revlink'] = getattr(self, 'revlink', None) result['properties'] = self.properties.asList() result['repository'] = getattr(self, 'repository', None) diff --git a/buildbot/status/web/changes.py b/buildbot/status/web/changes.py index b9306764117..c7ee97f823a 100644 --- a/buildbot/status/web/changes.py +++ b/buildbot/status/web/changes.py @@ -12,7 +12,7 @@ def __init__(self, change, num): self.title = "Change #%d" % num def content(self, req, cxt): - cxt['c'] = self.change.html_dict() + cxt['c'] = self.change.asDict() template = req.site.buildbot_service.templates.get_template("change.html") data = template.render(cxt) return data diff --git a/buildbot/status/web/templates/build.html b/buildbot/status/web/templates/build.html index 445e697805c..b8a51182152 100644 --- a/buildbot/status/web/templates/build.html +++ b/buildbot/status/web/templates/build.html @@ -185,7 +185,7 @@

All Changes:

    {% for c in ss.changes %}
  1. Change #{{ c.number }}

    - {{ change(c.html_dict()) }} + {{ change(c.asDict()) }}
  2. {% else %}
  3. no changes