summaryrefslogtreecommitdiff
path: root/maildir2rss.py
diff options
context:
space:
mode:
authoryvesf <yvesf@aurora.xapek.org>2010-02-20 22:50:36 +0100
committeryvesf <yvesf@aurora.xapek.org>2010-02-20 22:50:36 +0100
commit6e33a67a8cb5011081e4dfb78b3082dd86ce8886 (patch)
tree093775fedf0c5da0d58972c96cc08f9d30af6539 /maildir2rss.py
parent1c3d3d11bcc9fa4e9ec006d95bbe1d04f7bf5a1a (diff)
downloadfakesmtp-6e33a67a8cb5011081e4dfb78b3082dd86ce8886.tar.gz
fakesmtp-6e33a67a8cb5011081e4dfb78b3082dd86ce8886.zip
mhonarc, maildir 2 rss
Diffstat (limited to 'maildir2rss.py')
-rw-r--r--maildir2rss.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/maildir2rss.py b/maildir2rss.py
new file mode 100644
index 0000000..563a48f
--- /dev/null
+++ b/maildir2rss.py
@@ -0,0 +1,37 @@
+import datetime
+import PyRSS2Gen
+from mailbox import Maildir
+import os,sys
+
+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)))
+
+rss = PyRSS2Gen.RSS2(
+ title = "Spamfeed",
+ link = "http://www.xapek.org/~yvesf/spam",
+ description = "Spam spam spam",
+ lastBuildDate = datetime.datetime.now(),
+ items=items
+)
+rss.write_xml(sys.stdout)