Mercurial > hg > config
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/tablify.py Thu Oct 15 11:41:26 2009 -0400 @@ -0,0 +1,19 @@ +def tablify(table_lines, header=True): + table = '<table>\n' + if header: + tag, invtag = '<th> ', ' </th>' + else: + tag, invtag = '<td> ', ' </td>' + if not hasattr(table_lines, '__iter__'): + table_lines = ( table_lines, ) + for i in table_lines: + table += '<tr>' + if not hasattr(i, '__iter__'): + i = (i,) + for j in i: + table += tag + str(j) + invtag + table += '</tr>\n' + tag = '<td> ' + invtag = ' </td>' + table += '</table>' + return table