#!/usr/bin/env python import re # tytul,rodzaj,tresc,autor,data def make_header(): szablon = open("../templates/header.html",'r') imput = szablon.read() szablon.close() return imput def make_bridge(): szablon = open("../templates/bridge.html",'r') imput = szablon.read() szablon.close() return imput def make_footer(): szablon = open("../templates/footer.html",'r') imput = szablon.read() szablon.close() return imput def make_article(tytul,rodzaj,tresc,autor,data): u1 = """ <table border=0 cellpadding=0 cellspacing=0 width=500 frame=void rules=none> <tr> <td width=10 bgcolor='#000000'><font size=0> </td> <td width=370 bgcolor='#000000' valign=middle align=left><font face='Lucida Sans Unicode' size=2> """ u2 = """ </td> <td width=100 bgcolor='#000000' valign=middle align=right><font face='Lucida Sans Unicode' size=1> """ u3 = """ </td> <td width=10 bgcolor='#000000'><font size=0> </td> <td width=10><font size=0> </td> </tr> <tr> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=470 colspan=2 height=10 bgcolor='#333333'><font size=0> </td> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=10 height=10 bgcolor='#330000'><font size=0> </td> </tr> <tr> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=470 colspan=2 bgcolor='#333333' valign=top align=left><font face='Arial' size=2> """ u4 = """ </td> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=10 height=10 bgcolor='#330000'><font size=0> </td> </tr> <tr> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=470 colspan=2 height=10 bgcolor='#333333'><font size=0> </td> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=10 height=10 bgcolor='#330000'><font size=0> </td> </tr> <tr> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=470 colspan=2 height=10 valign=middle align=right bgcolor='#333333'><font face='Arial' size=1> """ u5 = """ <i> """ u6 = """ </i></td> <td width=10 height=10 bgcolor='#333333'><font size=0> </td> <td width=10 height=10 bgcolor='#330000'><font size=0> </td> </tr> <tr> <td width=10 height=10><font size=0> </td> <td width=470 colspan=2 height=10 bgcolor='#330000'><font size=0> </td> <td width=10 height=10 bgcolor='#330000'><font size=0> </td> <td width=10 height=10 bgcolor='#330000'><font size=0> </td> </tr> </table> <br> """ return u1 + tytul + u2 + rodzaj + u3 + tresc + u4 + autor + u5 + data + u6 def make_news(tytul,newsy): u1 = """ <br> <table border=0 cellpadding=0 cellspacing=0 width=200 frame=void rules=none> <tr> <td width=10 height=10 bgcolor='#444444'><font size=0> </td> <td width=170 height=10 bgcolor='#444444' valign=middle align=left><font face='Lucida Sans Unicode' size=2> """ u2 = """ </td> <td width=10 height=10 bgcolor='#444444'><font size=0> </td> <td width=10 height=10><font size=0> </td> </tr> <tr> <td width=10 height=10 bgcolor='#777777'><font size=0> </td> <td width=170 height=10 bgcolor='#777777'><font size=0> </td> <td width=10 height=10 bgcolor='#777777'><font size=0> </td> <td width=10 height=10 bgcolor='#440000'><font size=0> </td> </tr> <tr> <td width=10 bgcolor='#777777'><font size=0> </td> <td width=170 bgcolor='#777777' valign=top align=left><font face='Arial' size=2> """ u3 = """ </td> <td width=10 bgcolor='#777777'><font size=0> </td> <td width=10 bgcolor='#440000'><font size=0> </td> </tr> <tr> <td width=10 height=10 bgcolor='#777777'><font size=0> </td> <td width=170 height=10 bgcolor='#777777'><font size=0> </td> <td width=10 height=10 bgcolor='#777777'><font size=0> </td> <td width=10 height=10 bgcolor='#440000'><font size=0> </td> </tr> <tr> <td width=10 height=10><font size=0> </td> <td width=170 height=10 bgcolor='#440000'><font size=0> </td> <td width=10 height=10 bgcolor='#440000'><font size=0> </td> <td width=10 height=10 bgcolor='#440000'><font size=0> </td> </tr> </table><br> """ return u1 + tytul + u2 + newsy + u3 def make_page(): print "Content-Type: text/html\n\n" print make_header() print make_article("Tytuł","Rodzaj","Treść","Autor","Data") print make_bridge() grupy = ['pl.comp.os.linux','pl.comp.os.linux.programowanie','comp.lang.python', 'alt.pl.comp.os.hacking'] for i in grupy: l = open(i+'-index.html','r') imput = l.read() print make_news(i,imput) print make_footer() make_page()