[Piglit] [PATCH 4/7] HTML summary: Move the irregular entries to mako

Dylan Baker baker.dylan.c at gmail.com
Thu Oct 17 15:09:40 CEST 2013


This moves the irregular entries (like the tabs) to the mako template
and out of the summary module.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/summary.py | 32 ++++++++------------------------
 templates/index.mako | 31 +++++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/framework/summary.py b/framework/summary.py
index 8494d31..25ee320 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -112,26 +112,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')
-        for each in summary.results:
-            self._groupResult(summary.fractions[each.name]['all'],
-                              summary.status[each.name]['all'])
-        self._endRow()
-
         # Add the groups and tests to the out list
         for key in sorted(page):
 
@@ -496,10 +476,12 @@ class Summary:
         # alltests, where the other pages all use the same name. ie,
         # changes.html, self.changes, and page=changes.
         file = open(path.join(destination, "index.html"), 'w')
-        file.write(makoindex.render(results=HTMLIndex(self, self.tests['all']),
+        file.write(makoindex.render(old_results=HTMLIndex(self, self.tests['all']),
+                                    fractions=self.fractions,
+                                    status=self.status,
+                                    results=self.results,
                                     page='all',
                                     pages=pages,
-                                    colnum=len(self.results),
                                     exclude=exclude))
         file.close()
 
@@ -509,10 +491,12 @@ class Summary:
             # If there is information to display display it
             if self.tests[page]:
                 file.write(makoindex.render(
-                    results=HTMLIndex(self, self.tests[page]),
+                    old_results=HTMLIndex(self, self.tests[page]),
+                    fractions=self.fractions,
+                    status=self.status,
+                    results=self.results,
                     pages=pages,
                     page=page,
-                    colnum=len(self.results),
                     exclude=exclude))
             # otherwise provide an empty page
             else:
diff --git a/templates/index.mako b/templates/index.mako
index 5833718..429d184 100644
--- a/templates/index.mako
+++ b/templates/index.mako
@@ -1,3 +1,7 @@
+<%
+  from os import path
+%>
+
 <%namespace name="functions" file="functions.mako" />
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
@@ -32,11 +36,34 @@
 
         ## Status columns
         ## Create an additional column for each summary
-        % for _ in xrange(colnum):
+        % for _ in xrange(len(results)):
         <col />
         % endfor
       </colgroup>
-      % for line in results:
+
+      ## Create a new 'tab' for each result
+      ${functions.new_row()}
+      <td />
+      % for each in results:
+        <td class="head"><b>${each.name}</b><br />
+          <a href="${path.join(each.name, 'index.html')}">info</a>
+        </td>
+      % endfor
+      ${functions.end_row()}
+
+      ## Add the toplevel 'all' group
+      % for each in results:
+        ${functions.new_row()}
+        ${functions.group_row("head", 0, "all")}
+        ## FIXME: This can be changed to a group_result after the next loop is converted
+        <td class="${status[each.name]['all']}">
+          <b>${fractions[each.name]['all'][0]}/${fractions[each.name]['all'][1]}</b>
+        </td>
+        ${functions.end_row()}
+      % endfor
+
+      ## Generate the body of the index
+      % for line in old_results:
         % if line['type'] == "newRow":
           ${functions.new_row()}
         % elif line['type'] == "endRow":
-- 
1.8.1.5



More information about the Piglit mailing list