Give iwla to each display class
Add generic functions createPage() and createBlock() in DisplayHTMLBuild Add and display IWLA version
This commit is contained in:
32
display.py
32
display.py
@@ -3,7 +3,8 @@ import codecs
|
||||
|
||||
class DisplayHTMLRaw(object):
|
||||
|
||||
def __init__(self, html=u''):
|
||||
def __init__(self, iwla, html=u''):
|
||||
self.iwla = iwla
|
||||
self.html = html
|
||||
|
||||
def setRawHTML(self, html):
|
||||
@@ -21,8 +22,8 @@ class DisplayHTMLRaw(object):
|
||||
|
||||
class DisplayHTMLBlock(DisplayHTMLRaw):
|
||||
|
||||
def __init__(self, title=''):
|
||||
super(DisplayHTMLBlock, self).__init__(html='')
|
||||
def __init__(self, iwla, title=''):
|
||||
super(DisplayHTMLBlock, self).__init__(iwla, html='')
|
||||
self.title = title
|
||||
self.cssclass = u'iwla_block'
|
||||
self.title_cssclass = u'iwla_block_title'
|
||||
@@ -54,8 +55,8 @@ class DisplayHTMLBlock(DisplayHTMLRaw):
|
||||
|
||||
class DisplayHTMLBlockTable(DisplayHTMLBlock):
|
||||
|
||||
def __init__(self, title, cols):
|
||||
super(DisplayHTMLBlockTable, self).__init__(title=title)
|
||||
def __init__(self, iwla, title, cols):
|
||||
super(DisplayHTMLBlockTable, self).__init__(iwla=iwla, title=title)
|
||||
self.cols = listToStr(cols)
|
||||
self.rows = []
|
||||
self.cols_cssclasses = [u''] * len(cols)
|
||||
@@ -153,14 +154,12 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock):
|
||||
|
||||
class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable):
|
||||
|
||||
def __init__(self, title, cols, short_titles=None, nb_valid_rows=0, graph_cols=None):
|
||||
super(DisplayHTMLBlockTableWithGraph, self).__init__(title=title, cols=cols)
|
||||
def __init__(self, iwla, title, cols, short_titles=None, nb_valid_rows=0, graph_cols=None):
|
||||
super(DisplayHTMLBlockTableWithGraph, self).__init__(iwla=iwla, title=title, cols=cols)
|
||||
self.short_titles = short_titles or []
|
||||
self.short_titles = listToStr(self.short_titles)
|
||||
self.nb_valid_rows = nb_valid_rows
|
||||
# TOFIX
|
||||
self.icon_path = u'/resources/icon'
|
||||
# self.icon_path = self.iwla.getConfValue('icon_path', '/')
|
||||
self.icon_path = self.iwla.getConfValue('icon_path', '/')
|
||||
self.raw_rows = []
|
||||
self.maxes = [0] * len(cols)
|
||||
self.table_graph_css = u'iwla_graph_table'
|
||||
@@ -195,7 +194,7 @@ class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable):
|
||||
elif style.startswith(u'iwla_visit'): icon = u'vv.png'
|
||||
else: return ''
|
||||
|
||||
return u'%s/%s' % (self.icon_path, icon)
|
||||
return u'/%s/%s' % (self.icon_path, icon)
|
||||
|
||||
def _buildHTML(self):
|
||||
self._computeMax()
|
||||
@@ -236,7 +235,8 @@ class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable):
|
||||
|
||||
class DisplayHTMLPage(object):
|
||||
|
||||
def __init__(self, title, filename, css_path):
|
||||
def __init__(self, iwla, title, filename, css_path):
|
||||
self.iwla = iwla
|
||||
self.title = unicode(title)
|
||||
self.filename = filename
|
||||
self.blocks = []
|
||||
@@ -273,6 +273,8 @@ class DisplayHTMLPage(object):
|
||||
f.write(u'</head>')
|
||||
for block in self.blocks:
|
||||
block.build(f)
|
||||
f.write(u'<center>Generated by <a href="%s">IWLA %s</a></center>' %
|
||||
("http://indefero.soutade.fr/p/iwla", self.iwla.getVersion()))
|
||||
f.write(u'</body></html>')
|
||||
f.close()
|
||||
|
||||
@@ -282,6 +284,12 @@ class DisplayHTMLBuild(object):
|
||||
self.pages = []
|
||||
self.iwla = iwla
|
||||
|
||||
def createPage(self, *args):
|
||||
return DisplayHTMLPage(self.iwla, *args)
|
||||
|
||||
def createBlock(self, _class, *args):
|
||||
return _class(self.iwla, *args)
|
||||
|
||||
def getPage(self, filename):
|
||||
for page in self.pages:
|
||||
if page.getFilename() == filename:
|
||||
|
||||
Reference in New Issue
Block a user