#! /usr/bin/env python
import sys, string
f = open('TODO', 'r')
sys.stdout = open('admin/www/todo.html', 'w')
lines = f.readlines()
f.close()
for l in range(len(lines)):
  if lines[l][0] == '\f':
    l = l - 1
    break
i = 0
print "<HTML><HEAD><TITLE>The Mailman TODO list</TITLE></HEAD><BODY>"
while lines[i][0] <> '*':
  if string.strip(lines[i]) <>  '':
    print "<H1>",lines[i][:-1], "</H1>"
  i = i + 1
  if i == l: break

info = []
while 1:
  if lines[i][0] <> '*': break
  category = lines[i][1:-1]
  i = i + 1
  points = []
  while i<>l and lines[i][0] <> '*':
    if string.strip(lines[i]) == '': 
      i = i + 1
      continue
    if lines[i][0] == '-':
      points.append(lines[i][1:-1])
    elif len(points):
      if points[-1][-1] <> ' ' and lines[i][0] <> ' ':
        points[-1] = points[-1] + ' '
      points[-1] = points[-1] + lines[i][:-1]
    else:
      points.append(lines[i][:-1])
    i = i + 1
  info.append((category,points))
  if i == l: break
print '<H2>Categories:</H2>'
print '<UL>'
x = 1
for category, stuff in info:
  print '<LI><FONT SIZE=+1><A href=#c%d>%s</A></FONT></LI>' % (x,category)
  x = x + 1
print '</UL>'
print '<HR>'
x = 1
for category, stuff in info:
  print '<A NAME=c%d><H3>%s</H3>' % (x, category)
  x = x + 1
  print '<UL>'
  for item in stuff:
    print '<LI>%s</LI>' % item
  print '</UL>'
print '</BODY></HTML>'
