Commits

nakamura  committed 3aa7d06

don't call writeEntries() if no entries to save

To avoid unnecessary database open, don't call writeEntries() if there is no
entries to save.

  • Participants
  • Parent commits f3d8f5e

Comments (0)

Files changed (1)

File karintou/__init__.py

                     msg(u'drop: {0}'.format(entries[i].link))
                     break
 
+            # replace entry with translated one
             entries[i] = entry
 
+        # filter dropped entries, which is None
+        entries = filter(None, entries)
+
+        if not entries:
+            # no entries to save. return.
+            return
+
         retryCount = 10
         for i in range(retryCount):
             try:
     def writeEntries(self, entries, feed):
         with self.dbm.open(DatabaseManager.MODE.READ_WRITE) as db:
             for entry in entries:
-                if entry is None:
-                    continue
-
                 db.add(entry, feed.feed.title, feed.url, self.site.tags)
                 msg(u'add: {0}'.format(entry.link))