diff options
-rwxr-xr-x[-rw-r--r--] | maildir2rss.py | 47 | ||||
-rw-r--r-- | mhonarc.mrc | 3 |
2 files changed, 27 insertions, 23 deletions
diff --git a/maildir2rss.py b/maildir2rss.py index 563a48f..b50beef 100644..100755 --- 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) diff --git a/mhonarc.mrc b/mhonarc.mrc index a592be7..f352587 100644 --- a/mhonarc.mrc +++ b/mhonarc.mrc @@ -15,6 +15,9 @@ index.html 20 </IDXSIZE> +<!-- obscure email-addresses --> +<SPAMMODE> + <!-- add RSS link--> <IdxPgBegin> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |