[Piglit] [PATCH 3/6] Summary.py: Move code out of HTMLIndex into a mako template
Dylan Baker
baker.dylan.c at gmail.com
Mon Nov 4 08:53:44 PST 2013
Moving the column headers out of the HTMLIndex class simplifies the
class, since the code that existed for handling this was special case.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/summary.py | 17 +++++------------
templates/index_columns.mako | 7 +++++++
2 files changed, 12 insertions(+), 12 deletions(-)
create mode 100644 templates/index_columns.mako
diff --git a/framework/summary.py b/framework/summary.py
index 9333139..f5f3c9b 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -94,18 +94,6 @@ class HTMLIndex(list):
# written.
currentDir = []
- # Add a new 'tab' for each result
- self._newRow()
- self.append({'type': 'other', 'text': '<td />'})
- for each in summary.results:
- self.append({'type': 'other',
- 'text': '<td class="head"><b>%(name)s</b><br />'
- '(<a href="%(href)s">info</a>)'
- '</td>' % {'name': each.name,
- 'href': path.join(each.name,
- "index.html")}})
- self._endRow()
-
# Add the toplevel 'all' group
self._newRow()
self._groupRow("head", 0, 'all')
@@ -354,6 +342,7 @@ class Summary:
testindex = templates.get_template("testrun_info.mako")
testfile = templates.get_template("test_result.mako")
index_open = templates.get_template("index_open.mako")
+ index_columns = templates.get_template("index_columns.mako")
index_body = templates.get_template("index_body.mako")
index_close = templates.get_template("index_close.mako")
empty_status = templates.get_template("empty_status.mako")
@@ -407,10 +396,13 @@ class Summary:
# Index.html is a bit of a special case since there is index, all, and
# alltests, where the other pages all use the same name. ie,
# changes.html, self.changes, and page=changes.
+ names = [i.name for i in self.results]
+ names = itertools.izip(names, [path.join(i, "index.html") for i in names])
with open(path.join(destination, "index.html"), 'w') as out:
out.write(index_open.render(page='all',
pages=pages,
colnum=len(self.results)))
+ out.write(index_columns.render(zips=names))
out.write(index_body.render(results=HTMLIndex(self, self.tests['all']),
exclude=exclude))
out.write(index_close.render())
@@ -424,6 +416,7 @@ class Summary:
page=page,
pages=pages,
colnum=len(self.results)))
+ out.write(index_columns.render(zips=names))
out.write(index_body.render(
results=HTMLIndex(self, self.tests[page]),
exclude=exclude))
diff --git a/templates/index_columns.mako b/templates/index_columns.mako
new file mode 100644
index 0000000..f6615ae
--- /dev/null
+++ b/templates/index_columns.mako
@@ -0,0 +1,7 @@
+## Add a new 'tab' for each result
+<tr>
+ <td />
+ % for (name, href) in zips:
+ <td class="head"><b>${name}</b><br />(<a href="${href}"?>info</a>)</td>
+ % endfor
+</tr>
\ No newline at end of file
--
1.8.1.5
More information about the Piglit
mailing list