Skip to content

Commit

Permalink
Replace Change's html_dict() with asDict() (see buildbot#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sonestedt committed Apr 5, 2010
1 parent b0a9da2 commit 2fa3b3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion buildbot/broken_test/runs/test_status.py
Expand Up @@ -174,7 +174,7 @@ def customHTMLMailMessage(attrs):
attrs['result'].title()))
text.append("<h4>Recent Changes:</h4>")
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("<h4>Last %d lines of '%s':</h4>" % (logLines, name))
Expand Down
27 changes: 7 additions & 20 deletions buildbot/changes/changes.py
Expand Up @@ -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)
Expand All @@ -101,33 +103,18 @@ 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
result['category'] = self.category
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)
Expand Down
2 changes: 1 addition & 1 deletion buildbot/status/web/changes.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion buildbot/status/web/templates/build.html
Expand Up @@ -185,7 +185,7 @@ <h2>All Changes:</h2>
<ol>
{% for c in ss.changes %}
<li><h3>Change #{{ c.number }}</h3>
{{ change(c.html_dict()) }}
{{ change(c.asDict()) }}
</li>
{% else %}
<li>no changes</li>
Expand Down

0 comments on commit 2fa3b3b

Please sign in to comment.