iwla

iwla Commit Details

Date:2015-01-13 18:55:46 (6 years 6 months ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:616b0d80527bc0c3ab2bb799c7c8fb3e66be3afa
Parents: 1d9bf71b4b2df090038a52bd3e39c3785d14d60b
Message:Add computeRatio method to display. Enable it in browsers display plugin

Changes:
Mdisplay.py (2 diffs)
Mplugins/display/browsers.py (1 diff)

File differences

display.py
102102
103103
104104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
105120
106121
107122
......
160175
161176
162177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
163192
164193
165194
self.rows.append(listToStr(row))
self.rows_cssclasses.append([u''] * len(row))
def insertCol(self, col_number, col_title='', col_css_class=''):
self.cols.insert(col_number, col_title)
for r in self.rows:
r.insert(col_number, u'')
for r in self.rows_cssclasses:
v = r[0]
# If all cells have the same CSS class, set it
for cur_value in r:
if v != cur_value:
v = None
break
v = v or u''
r.insert(col_number, v)
self.cols_cssclasses.insert(col_number, col_css_class)
def getNbRows(self):
return len(self.rows)
self.cols_cssclasses = listToStr(values)
def computeRatio(self, column, column_insertion=None):
if column_insertion is None:
column_insertion = column+1
total = 0
for r in self.rows:
if r[column]:
total += int(r[column])
self.insertCol(column_insertion, self.iwla._('Ratio'), u'iwla_hit')
for (index, r) in enumerate(self.rows):
val = r[column] and int(r[column]) or 0
self.setCellValue(index, column_insertion, '%.1f%%' % (float(val*100)/float(total)))
def _buildHTML(self):
style = u''
if self.table_css: style = u' class="%s"' % (self.table_css)
plugins/display/browsers.py
128128
129129
130130
131
131132
total_browsers[1] = self.iwla._(u'Others')
table.appendRow(total_browsers)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
table.computeRatio(2)
index.appendBlock(table)

Archive Download the corresponding diff file

Branches

Tags