todoをhtmlで出力する

い忙しい・・

""" TODOをHTMLで出力するためのモジュール
inputlist::[(title, content)]
"""
HTML = "<html><head><title>todo</title></head><body>%s</body></html>" 

def listup(lst):
    ret = ""
    for n in lst:
        ret += "<li>%s</li>" % n
    return ret

def makelist(lst):
    lst = listup(lst)
    temp = "<ul>%s</ul>"
    return temp % lst

def maketodo(inputlist):
    embed = ""
    for n in inputlist:
        embed += "<h2>%s</h2>%s" % (n[0], makelist(n[1]))
    return HTML % embed

def main(titlelist, contentlist, filename):
    """example:
    titlelist = ["todo", "hobby", "else"]
    contentlist = [["write program", "submit bug report"],
                   ["make figure", "plane RC"],
                   ["hogehoge"]]
    main(titlelist, contentlist, "out.html")
    """
    inputlist = zip(titlelist, contentlist)
    f = open(filename, "w")
    content = maketodo(inputlist)
    f.write(content)
    f.close()