import os
import sys
from commands import getoutput
import time

def mkmohtml():
    dirl = os.listdir('.')
    # 1980.html
    # 198101.shtml
    # 198102.shtml
    # 1981.html

    spl = os.getcwd().split('/')
    yyyy = spl[len(spl)-1]
    fo = open(yyyy+'.html', 'w')
    preamble(fo, yyyy)
    for fn in dirl:
        try:
            if fn[-6:] != '.shtml':
                continue
            time.strptime(fn[0:6],'%Y%m')
        except:
            continue
        f = open(fn)
        lines = f.readlines()
        f.close()
        for l in lines:
            # <br><a href=http://www.hbeck.net/cgi-bin/txt2html4.py?yyyy=1981&txtfn=198101_beach_beach.txt>January 1981 - Beach</a>
            # <p><a href=198005.shtml>May - Little League</a>
            if l.find('href') == -1:
                continue
            
            print l
        sys.exit()

def preamble(fo, yyyy)
    fo.write('<html><body>\n')
    fo.write('<font size=+1><p>'+yyyy+'</font>\n')
:d

    return

mkmohtml()

# <html><body>
# <font size=+1><p>1980<p></font>
# <p><a href=198003.shtml>March - Ladies Cross Country</a>
# <p><a href=198005.shtml>May - Little League</a>
# <p><a href=198008.shtml>August - British Columbia</a>
# <p><a href=198012.shtml>Christmas</a>
# </body></html>


