| 1 | def html_tag(tag, txt, attrs=None): |
| 2 | html = '<%s' |
| 3 | if attrs: |
| 4 | for name in attrs: |
| 5 | html += ' %s="%s"' % (name, attrs[name]) |
| 6 | html += '>%s</%s>\n' |
| 7 | html = html % (tag, txt, tag) |
| 8 | |
| 9 | return html |
| 10 | |
| 11 | def html_th(header, attrs=None): |
| 12 | html = '' |
| 13 | for d in header: |
| 14 | html += html_tag('th', d, attrs=attrs) |
| 15 | return html_tag('tr', html) |
| 16 | |
| 17 | def html_tr(data): |
| 18 | html = '' |
| 19 | for d in data: |
| 20 | html += html_tag('td', d) |
| 21 | return html_tag('tr', html) |
| 22 | |
| 23 | def html_link(href, txt): |
| 24 | html = '<a href="%s" target="_blank">%s</a>' % (href, txt) |
| 25 | return html |