[Tutor] HTML project

Paul Brown clanoftheinsane@hotmail.com
Sat, 14 Jul 2001 21:11:29 -0400


<html><DIV>hey all,</DIV>
<DIV>i am working on a project with Python.&nbsp; some of my friends have a email-list going around, and somebody writes a daily (well, almost daily) devotional and sends it to everyone.&nbsp; i'm wanting to put all of these on a website, and i'm gonna use python to write the html files.&nbsp; i've got most of what i want complete, but i can't figure out the rest.&nbsp; all of the devotionals i have saved into a big text document, separated by a common string: "Date:" and then it displays the date, in the form of Month ##th, 2000.&nbsp; (or "st" and "2001" in their respective places).&nbsp; i want to create an actual HTML file in the following format:&nbsp; month##.html (all lowercase, double digits for the numbers to keep them in order).&nbsp; what i've got so far is the python script that prints the whole file to the stdout, and it inserts the headings with the appropriate dates.&nbsp; another thing i want to do is have the script write in the paragraph tag (&lt;p&gt;) whenever there is two linebreaks.&nbsp; would that be possible?&nbsp; here is my script so far:</DIV>
<DIV>&nbsp;</DIV>
<DIV>import sys<BR>file=open('c:\windows\desktop\goodtext', 'r')</DIV>
<DIV>br="Date:"</DIV>
<DIV>for line in file.readlines():<BR>&nbsp;if line[:5] != br:<BR>&nbsp;&nbsp;&nbsp;&nbsp; if line[:-1]=="\n":<BR>&nbsp;&nbsp;print "&lt;p&gt;", line,<BR>&nbsp;&nbsp;&nbsp;&nbsp; else:<BR>&nbsp;&nbsp;print line,<BR>&nbsp;else:<BR>&nbsp;&nbsp;sys.stdout.write(line[5:])<BR>&nbsp;&nbsp;print '''&lt;html&gt;<BR>&lt;head&gt;<BR>&lt;title&gt;%s&lt;/title&gt;<BR>&lt;/head&gt;<BR>&lt;BODY&gt;</DIV>
<DIV>&lt;center&gt;&lt;h1&gt;%s&lt;/h1&gt;&lt;/center&gt;<BR>''' %(line[5:], line[5:])</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>any suggestions?&nbsp; thanks</DIV>
<DIV>paul brown</DIV><br clear=all><hr>Get your FREE download of MSN Explorer at <a href="http://explorer.msn.com">http://explorer.msn.com</a><br></p></html>