1
0

mktable.py 465 B

12345678910111213141516171819202122
  1. #!/usr/bin/env python
  2. import re
  3. def convert(line, head = False):
  4. pat = re.compile(r'([$]\S*)')
  5. line = pat.sub(r'<code>\1</code>', line)
  6. row = [x.strip() for x in line.split('|')]
  7. fmt = ' <tr><td>%s</td><td>%s</td></tr>'
  8. if head:
  9. fmt = fmt.replace('td', 'th')
  10. print fmt % tuple(row)
  11. f = file('parameters.txt')
  12. print '<table>'
  13. convert(f.readline(), head = True)
  14. f.readline()
  15. for line in f:
  16. convert(line)
  17. print '</table>'