terom@80: """ terom@80: Uses PyRSS2Gen to generate XML RSS documents terom@80: """ terom@80: terom@80: import PyRSS2Gen as RSS2Gen terom@80: import datetime, pytz terom@80: terom@80: class RSSFormatter (object) : terom@80: """ terom@80: Mixin for LogFormatter that implements the basic RSS-rendering stuff on top of format_html terom@80: """ terom@80: terom@80: def format_rss (self, lines, **kwargs) : terom@80: """ terom@80: Process using format_html terom@80: """ terom@80: terom@80: # build the RSS2 object and return the XML terom@80: return RSS2Gen.RSS2( terom@80: title = "IRC RSS feed", terom@80: link = "http://irclogs.qmsk.net/", terom@80: description = "A stupid RSS feed that nobody sane would ever use", terom@80: terom@80: # XXX: GMT terom@80: lastBuildDate = datetime.datetime.utcnow(), terom@80: terom@80: items = [ terom@80: RSS2Gen.RSSItem( terom@80: # use the formatted HTML data as the title terom@80: title = html_data, terom@80: terom@80: # timestamp terom@80: pubDate = line.timestamp.astimezone(pytz.utc), terom@80: terom@80: # link terom@80: link = "http://xxx/", terom@80: terom@80: ) for line, html_data in self.format_html(lines, **kwargs) terom@80: ] terom@80: ).to_xml('utf8') terom@80: