def bibList(self, bibs): bibs = [b for b in bibs if b] html = StringIO() with tag(html, 'ul', 'bibList'): for bib in bibs: with tag(html, 'li'): html.write(self.bibField(bib)) return html.getvalue()
def bibList( self, bibs ): bibs = [b for b in bibs if b] html = StringIO() with tag( html, 'ul', 'bibList' ): for bib in bibs: with tag( html, 'li' ): html.write( self.bibField(bib) ) return html.getvalue()
def bibList( self, bibs ): html = StringIO() with tag( html, 'ul', 'bibList' ): for bib in bibs: if not bib: continue with tag( html, 'li' ): html.write( self.bibField(bib) ) return html.getvalue()
def bibTable(self, bibs): bibs = [b for b in bibs if b] if not bibs: return '<br/>' GetTranslation = _ html = StringIO() with tag(html, 'table', 'bibTable'): with tag(html, 'thead'): with tag(html, 'tr'): for f in ['Bib#'] + self.fields: with tag(html, 'th', {'style': "text-align:left"} if 'Bib' in f else {'style': "text-align:left"}): html.write(GetTranslation(f)) with tag(html, 'tbody'): for bib in bibs: with tag(html, 'tr'): data = self.getData(bib) with tag(html, 'td', {'style': "text-align:right"}): html.write(unicode(bib)) for f in self.fields: with tag(html, 'td', {'style': "text-align:left"}): if 'Name' in f: with tag(html, 'strong'): html.write(cgi.escape(data.get(f, u''))) else: html.write(cgi.escape(data.get(f, u''))) return html.getvalue()
def bibTable( self, bibs ): bibs = [b for b in bibs if b] if not bibs: return '<br/>' GetTranslation = _ html = StringIO() with tag( html, 'table', 'bibTable' ): with tag( html, 'thead' ): with tag( html, 'tr' ): for f in ['Bib#'] + self.fields: with tag( html, 'th', {'style':"text-align:left"} if 'Bib' in f else {'style':"text-align:left"} ): html.write( GetTranslation(f) ) with tag( html, 'tbody' ): for bib in bibs: with tag( html, 'tr' ): data = self.getData( bib ) with tag( html, 'td', {'style':"text-align:right"} ): html.write( unicode(bib) ) for f in self.fields: with tag( html, 'td', {'style':"text-align:left"}): if 'Name' in f: with tag( html,'strong'): html.write( cgi.escape(data.get(f,u'')) ) else: html.write( cgi.escape(data.get(f,u'')) ) return html.getvalue()
def toHtml( self, html, attrs={} ): topBorder = set() bottomBorder = set() leftBorder = set() rightBorder = set() numberRows, numberCols = self.getNumberRows(), self.getNumberCols() for row, colStart, colEnd, thick in self.hLines: if row < numberRows: for col in range(colStart, colEnd): topBorder.add( (row, col) ) else: for col in range(colStart, colEnd): bottomBorder.add( (numberRows-1, col) ) for col, rowStart, rowEnd, think in self.vLines: if col < numberCols: for row in range(rowStart, rowEnd): leftBorder.add( (row, col) ) else: for row in range(rowStart, rowEnd): rightBorder.add( (row, numberCols-1) ) with tag( html, 'table', attrs ): with tag( html, 'tbody' ): for row, r in enumerate(self.table): with tag( html, 'tr' ): for col in range(numberCols): value, attr = r[col] if col < len(r) else (u'', 0) value = u'{}'.format(value) classDef = [] if (row, col) in topBorder: classDef.append('topBorder') if (row, col) in bottomBorder: classDef.append('bottomBorder') if (row, col) in leftBorder: classDef.append('leftBorder') if (row, col) in rightBorder: classDef.append('rightBorder') if (attr & self.alignRight) and value: classDef.append('rightAlign') attrs = {'class': ' '.join(classDef)} if classDef else {} with tag( html, 'td', attrs ): if (attr & self.bold) and value: with tag( html, 'strong' ): html.write( cgi.escape(value) ) else: html.write( cgi.escape(value) )