See ChangeLog
[planet-ucc.git] / RSS2Writer.py
1 import time
2
3 class RSS2Writer:
4         def __init__(self, planet):
5                 self.planet     = planet
6                 self.maxitems   = 50
7                 self.parent     = None
8         
9         def __write_item__(self, item):
10                 output  =       ''
11                 output  +=      '<item>\n'
12                 output  +=      ' <title>%s: %s</title>\n' % (item.blogTitle, item.itemTitle)
13                 output  +=      ' <guid>%s</guid>\n' % item.itemURL
14                 output  +=      ' <link>%s</link>\n' % item.itemURL
15                 output  +=      ' <description>\n'
16                 output  +=      item.contents
17                 output  +=      '\n </description>\n'
18                 output  +=      '<pubDate>%s</pubDate>\n' % time.strftime('%a, %d %b %Y %H:%M:%S +0000', time.gmtime(item.itemDate))
19                 output  +=      '</item>\n'
20                 return output
21         
22         def write(self):
23                 itemcount       = 0
24                 output  =       ''
25                 output  +=      '<rss version="2.0">\n'
26                 output  +=      ' <channel>\n'
27                 output  +=      '  <title>Planet UCC</title>\n'
28                 output  +=      '  <link>http://planet.ucc.asn.au/</link>\n'
29                 output  +=      '  <language>en</language>\n'
30                 output  +=      '  <description>Planet UCC</description>\n'
31                 for date in self.planet:
32                         for item in date.items:
33                                 output  += self.__write_item__(item)
34                                 itemcount += 1
35                                 if itemcount >= self.maxitems:
36                                         break
37                         if itemcount >= self.maxitems:
38                                 break
39                 output  +=      ' </channel>\n'
40                 output  +=      '</rss>\n'
41                 return output

UCC git Repository :: git.ucc.asn.au