comparison python/tablify.py @ 0:f3ab51c79813

adding configuration from https://svn.openplans.org/svn/config_jhammel/
author k0s <k0scist@gmail.com>
date Thu, 15 Oct 2009 11:41:26 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f3ab51c79813
1 def tablify(table_lines, header=True):
2 table = '<table>\n'
3 if header:
4 tag, invtag = '<th> ', ' </th>'
5 else:
6 tag, invtag = '<td> ', ' </td>'
7 if not hasattr(table_lines, '__iter__'):
8 table_lines = ( table_lines, )
9 for i in table_lines:
10 table += '<tr>'
11 if not hasattr(i, '__iter__'):
12 i = (i,)
13 for j in i:
14 table += tag + str(j) + invtag
15 table += '</tr>\n'
16 tag = '<td> '
17 invtag = ' </td>'
18 table += '</table>'
19 return table