Starting point of rss2maildir:
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 19 Dec 2007 10:58:03 +0000 (10:58 +0000)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 19 Dec 2007 10:58:03 +0000 (10:58 +0000)
    * Config parser
    * Options parser

CHANGES [new file with mode: 0644]
README [new file with mode: 0644]
rss2maildir.conf.example [new file with mode: 0644]
rss2maildir.py [new file with mode: 0755]

diff --git a/CHANGES b/CHANGES
new file mode 100644 (file)
index 0000000..bdb9fd5
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,4 @@
+2007-12-19
+----------
+
+Initial starting points, config parser and option parsers
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..74b04f4
--- /dev/null
+++ b/README
@@ -0,0 +1,15 @@
+rss2maildir
+=========
+
+Introduction
+------------
+
+rss2maildir takes rss feeds and creates a maildir of messages for each of the
+feeds, new items become "new", updated entries also get marked as new when they
+are updated. Each feed becomes it's own maildir which can be named as you like.
+
+Usage
+-----
+
+Create a config file containing the feeds and their "names" - the names will be
+used as the directory name of the maildir for the feed.
diff --git a/rss2maildir.conf.example b/rss2maildir.conf.example
new file mode 100644 (file)
index 0000000..677687a
--- /dev/null
@@ -0,0 +1,8 @@
+[general]
+maildir_root = RSSMaildir
+
+[http://www.sommitrealweird.co.uk/blog/?flav=atom]
+name = Brett Parker
+email = iDunno@sommitrealweird.co.uk
+maildir = sommitrealweird
+
diff --git a/rss2maildir.py b/rss2maildir.py
new file mode 100755 (executable)
index 0000000..cece696
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+
+import mailbox
+import sys
+import os
+
+from optparse import OptionParser
+from ConfigParser import SafeConfigParser
+
+# first off, parse the command line arguments
+
+oparser = OptionParser()
+oparser.add_option(
+    "-c", "--conf", dest="conf",
+    help="location of config file"
+    )
+
+(options, args) = oparser.parse_args()
+
+# check for the configfile
+
+configfile = None
+
+if options.conf != None:
+    # does the file exist?
+    try:
+        os.stat(options.conf)
+        configfile = options.conf
+    except:
+        # should exit here as the specified file doesn't exist
+        sys.stderr.write("Config file %s does not exist. Exiting.\n" %(options.conf,))
+        sys.exit(2)
+else:
+    # check through the default locations
+    try:
+        os.stat("%s/.rss2maildir.conf" %(os.environ["HOME"],))
+        configfile = "%s/.rss2maildir.conf" %(os.environ["HOME"],)
+    except:
+        try:
+            os.stat("/etc/rss2maildir.conf")
+            configfile = "/etc/rss2maildir.conf"
+        except:
+            sys.stderr.write("No config file found. Exiting.\n")
+            sys.exit(2)
+
+# Right - if we've got this far, we've got a config file, now for the hard
+# bits...
+
+scp = SafeConfigParser()
+scp.read(configfile)
+
+maildir_root = "RSSMaildir"
+
+if scp.has_option("general", "maildir_root"):
+    maildir_root = scp.get("general", "maildir_root")
+
+feeds = scp.sections()
+try:
+    feeds.remove("general")
+except:
+    pass
+
+for section in feeds:
+    print section
+    print "-" * len(section)
+    print scp.items(section)