diff --git a/display.py b/display.py
index 6750309..33b9f13 100644
--- a/display.py
+++ b/display.py
@@ -8,11 +8,15 @@ class DisplayHTMLRaw(object):
def setRawHTML(self, html):
self.html = html
+ def _buildHTML(self):
+ pass
+
def _build(self, f, html):
if html: f.write(html)
-
+
def build(self, f):
- self._build(self.html)
+ self._buildHTML()
+ self._build(f, self.html)
class DisplayHTMLBlock(DisplayHTMLRaw):
@@ -38,14 +42,14 @@ class DisplayHTMLBlock(DisplayHTMLRaw):
def setValueCSSClass(self, cssclass):
self.value_cssclass = cssclass
- def build(self, f):
+ def _buildHTML(self):
html = '
' % (self.cssclass)
if self.title:
html += '
%s
' % (self.title_cssclass, self.title)
html += '
%s
' % (self.value_cssclass, self.html)
html += '
'
- self._build(f, html)
+ self.html = html
class DisplayHTMLBlockTable(DisplayHTMLBlock):
@@ -113,30 +117,40 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock):
self.cols_cssclasses = values
- def build(self, f):
- if not self.html:
- html = ''
- if self.cols:
- html += ''
- for i in range (0, len(self.cols)):
- title = self.cols[i]
- style = self.getColCSSClass(i)
- if style: style = ' class="%s"' % (style)
- html += '%s | ' % (style, title)
- html += '
'
- for i in range(0, len(self.rows)):
- row = self.rows[i]
- html += ''
- for j in range(0, len(row)):
- v = row[j]
- style = self.getCellCSSClass(i, j)
- if style: style = ' class="%s"' % (style)
- html += '%s | ' % (style, v)
- html += '
'
- html += '
'
- self.html = html
+ def _buildHTML(self):
+ html = ''
+ if self.cols:
+ html += ''
+ for i in range (0, len(self.cols)):
+ title = self.cols[i]
+ style = self.getColCSSClass(i)
+ if style: style = ' class="%s"' % (style)
+ html += '%s | ' % (style, title)
+ html += '
'
+ for i in range(0, len(self.rows)):
+ row = self.rows[i]
+ html += ''
+ for j in range(0, len(row)):
+ v = row[j]
+ style = self.getCellCSSClass(i, j)
+ if style: style = ' class="%s"' % (style)
+ html += '%s | ' % (style, v)
+ html += '
'
+ html += '
'
- super(DisplayHTMLBlockTable, self).build(f)
+ self.html = html
+
+ super(DisplayHTMLBlockTable, self)._buildHTML()
+
+class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable):
+
+ def __init__(self, title, cols, short_title, nb_valid_rows=0):
+ super(DisplayHTMLBlockTableWithGraph, self).__init__(title=title, cols=cols)
+ self.short_title = short_title
+ self.nb_valid_rows = nb_valid_rows
+
+ def setNbValidRows(self, nb_valid_rows):
+ self.nb_valid_rows = nb_valid_rows
class DisplayHTMLPage(object):