From a2450062c993b097e9763ad312ad9292f0a33dda Mon Sep 17 00:00:00 2001 From: yvesf Date: Tue, 23 Feb 2010 08:07:20 +0100 Subject: use SPAMMODE in mhonarc --- maildir2rss.py | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) mode change 100644 => 100755 maildir2rss.py (limited to 'maildir2rss.py') diff --git a/maildir2rss.py b/maildir2rss.py old mode 100644 new mode 100755 index 563a48f..b50beef --- a/maildir2rss.py +++ b/maildir2rss.py @@ -1,37 +1,38 @@ +#!/usr/bin/python import datetime import PyRSS2Gen from mailbox import Maildir import os,sys -maildir=Maildir(os.path.dirname(os.path.abspath(__file__)) + "/Maildir") +def genItems(): + maildir=Maildir(os.path.dirname(os.path.abspath(__file__)) + "/Maildir") -items=[] -for key in maildir.keys(): - msg = maildir[key] - try: - subject = msg['subject'] - author=msg['from'] - msg.rewindbody() - description = msg.fp.read() - rfcdate = msg.getdate('date') - date=datetime.datetime(*rfcdate[:-2]) - item=PyRSS2Gen.RSSItem( - title=subject, - author=author, - link="http://xapek.org", - description=description, - pubDate=date - ) - items.append(item) - sys.stderr.write( "processed %s\n" % key) - except Exception,e: - sys.stderr.write("skip %s: %s\n" % (key,str(e))) + for key in maildir.keys(): + msg = maildir[key] + try: + subject = msg['subject'] + author=msg['from'] + msg.rewindbody() + description = msg.fp.read() + rfcdate = msg.getdate('date') + date=datetime.datetime(*rfcdate[:-2]) + item=PyRSS2Gen.RSSItem( + title=subject, + author=author, + link="http://xapek.org", + description=description, + pubDate=date + ) + yield item + sys.stderr.write( "processed %s\n" % key) + except Exception,e: + sys.stderr.write("skip %s: %s\n" % (key,str(e))) rss = PyRSS2Gen.RSS2( title = "Spamfeed", link = "http://www.xapek.org/~yvesf/spam", description = "Spam spam spam", lastBuildDate = datetime.datetime.now(), - items=items + items=list(genItems()) ) rss.write_xml(sys.stdout) -- cgit v1.2.1