import datetime def top10_to_html( top10 ): """ Converts a top10 object to HTML """ html = "" html += """ """ if top10.has_key('next'): html+= " \n" if top10.has_key('prev'): html+= " \n" if top10.has_key('first'): html+= " \n" if top10.has_key('last'): html+= " \n" html += " Potater Top 10: "+ str(top10['date']) + "\n" html += """ """ if len(top10['top10']) >= 10: html += "
" html += """ What? RSS

Potater Top 10

""" html += top10['author'] html += """
""" html += top10['date'] html += """
""" if len(top10['top10'] ) % 2 == 1: #odd html += "
\n" for j in range( 0, len(top10['top10']) ): i = len(top10['top10']) - 1 - j item = top10['top10'][i] if i == 9 or (i % 2 == 1 and i > 9): html += "
\n" if i == 7: html += "
\n" if i == 5: html += "
\n" if i == 3: html += "
\n" if i == 1: html += "
\n" if i < 0: html += "" if i % 2 == 1: #odd html += "\t
\n" if i % 2 == 0: #even html += "\t
\n" html += "\t\t
"+str(i)+".
\n" html += "\t\t
\n" html += "\t\t\t

"+item['title']+"

\n" html += "\t\t\t"+item['body']+"\n" html += "\t\t
\n" html += "\t\t
\n" if i % 2 == 0: #even html += "\t\t
\n" html += "\t
\n" html += """
""" if len(top10['top10']) >= 10: html += "
" html += """ """ if not ( top10.has_key('location') and top10['location'].endswith('index.html') ): html += """ """ html += """ """ return html