Commits

Moritz Wilhelmy committed 65bf95b

fix folder support

  • Participants
  • Parent commits 23d3bcc

Comments (0)

Files changed (1)

 from email.MIMEText import MIMEText
 from email.utils    import formatdate, mktime_tz
 from email.Header   import Header
+from os.path        import expanduser, basename
 
 try:
 	import cPickle as pickle
 	import pickle
 
 ######
-home   = os.getenv("HOME") or "."
-base   = home + "/lib/feeds/"
+base   = expanduser("~/lib/feeds/")
 furls  = base + "feeds" # textfile containing urls.
 fseen  = base + "seen"  # things that have already been sent, just pickle it..
 renderc= "elinks -dump /dev/stdin"
-# should also be possible to send them with sendmail if you need it..
-mbox   = mailbox.Maildir(home + "/.Maildir/.feeds")
+mailbox_format = mailbox.Maildir # edit this if you prefer mbox...
+open_mailbox = lambda x: mailbox_format(expanduser(x))
+mbox   = open_mailbox("~/.Maildir/.feeds")
 ######
 
 class Bug(Exception):
 
 		if folder:
 			try:
-				fbox = mbox.get_folder(folder)
+				fbox = open_mailbox(folder)
 			except:
-				fbox = mbox.add_folder(folder)
+				fbox = mbox
 		else:
 			fbox = mbox
 
 	except getopt.GetoptError, err:
 		print str(err)
 		print
-		print "Usage: %s [-e/--expunge url] [-l/--list]" % os.path.basename(sys.argv[0])
+		print "Usage: %s [-e/--expunge url] [-l/--list]" % basename(sys.argv[0])
 		print "  -l: list all entries in seen-file"
 		print "  -e: remove all entries of a certain feed"
 		print "Without any options, update all feeds specified in the feeds-file"