rss2email: don't create directories for files in the current directory.
authorW. Trevor King <wking@tremily.us>
Thu, 18 Oct 2012 12:41:09 +0000 (08:41 -0400)
committerW. Trevor King <wking@tremily.us>
Thu, 18 Oct 2012 12:41:09 +0000 (08:41 -0400)
This avoids:

  $ ./rss2email.py -d feeds.dat new
  ...
  OSError: [Errno 2] No such file or directory: ''

rss2email.py

index 7a94c5f3d1c54b66b3a28dad09111ce626fe0cb2..e994bb4b899f9d42880d62ee29cdc8ffbc15c36f 100755 (executable)
@@ -1350,7 +1350,7 @@ class Feeds (list):
         for feed in self:
             feed.save_to_config()
         dirname = _os.path.dirname(self.configfiles[-1])
-        if not _os.path.isdir(dirname):
+        if dirname and not _os.path.isdir(dirname):
             _os.makedirs(dirname)
         with open(self.configfiles[-1], 'w') as f:
             self.config.write(f)
@@ -1359,7 +1359,7 @@ class Feeds (list):
     def _save_feeds(self):
         LOG.debug('save feed data to {}'.format(self.datafile))
         dirname = _os.path.dirname(self.datafile)
-        if not _os.path.isdir(dirname):
+        if dirname and not _os.path.isdir(dirname):
             _os.makedirs(dirname)
         if UNIX:
             tmpfile = self.datafile + '.tmp'