Add rss2email v2.28 v2.28
authorAaron Swartz <me@aaronsw.com>
Mon, 2 Feb 2004 12:00:00 +0000 (12:00 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 15 Feb 2013 16:37:53 +0000 (11:37 -0500)
--no-send option for run, fixed FORCE_FROM. Tx Alan D.

Downloaded from:

  http://web.archive.org/web/20040416224157/http://www.aaronsw.com/2002/rss2email/rss2email-2.28.py

rss2email.py

index b237e41cf495b683f60112a6abfec1d7968e3246..b7d1d75eb2584f770025c60e6ce56f888f5ab514 100644 (file)
@@ -7,12 +7,12 @@ Usage: python rss2email.py feedfile action [options]
   action [options]:
        new [youremail] (create new feedfile)
        email [yournewemail] (update default email)
-       run
+       run [--no-send]
        add feedurl [youremail]
        list
        delete n
 """
-__version__ = "2.27"
+__version__ = "2.28"
 __author__ = "Aaron Swartz (me@aaronsw.com)"
 __copyright__ = "(C) 2004 Aaron Swartz. GNU GPL 2."
 ___contributors__ = ["Dean Jackson (dino@grorg.org)", 
@@ -157,7 +157,7 @@ def run():
                
                headers = "From: "
                if c.has_key('title'): headers += quoteEmailName(e(c, 'title')) + ' '
-               if c.has_key(ert) and c[ert].startswith('mailto:'):
+               if FORCE_FROM and c.has_key(ert) and c[ert].startswith('mailto:'):
                        fr = c[ert][7:]
                else:
                        fr = DEFAULT_FROM
@@ -236,22 +236,38 @@ def email(addr):
        else: feeds = [addr] + feeds
        unlock(feeds, ff2)
 
-if __name__ == "__main__":
-       if len(sys.argv) < 3: print __doc__
-       else: 
-               feedfile, action = sys.argv[1], sys.argv[2]
+if __name__ == '__main__':
+       ie, args = "InputError", sys.argv
+       try:
+               if len(args) < 3: raise ie, "insufficient args"
+               feedfile, action, args = args[1], args[2], args[3:]
                
-               if action == "run": run()
+               if action == "run": 
+                       if args and args[0] == "--no-send":
+                               def send(x,y,z):
+                                       if VERBOSE: print 'Not sending', (
+                                       [x for x in z.splitlines() if x.startswith("Subject:")][0])
+                       run()
+
                elif action == "email":
-                       email(sys.argv[3])
-                       print "Warning: Feed IDs may have changed. Run `list` before `delete`."
-               elif action == "add": add(*sys.argv[3:])
+                       email(args[0])
+                       print "W: Feed IDs may have changed. Run `list` before `delete`."
+
+               elif action == "add": add(*args)
+
                elif action == "new": 
-                       if len(sys.argv) == 4: d = [sys.argv[3]]
+                       if len(args) == 1: d = [args[0]]
                        else: d = []
                        pickle.dump(d, open(feedfile, 'w'))
+
                elif action == "list": list()
-               elif action == "delete": delete(int(sys.argv[3]))
+
+               elif action == "delete": delete(int(args[0]))
+
                else:
-                       print __doc__
-               
\ No newline at end of file
+                       raise ie, "invalid action"
+                       
+       except ie, e:
+               print "E:", e
+               print
+               print __doc__
\ No newline at end of file