Instead of raising a TypeError from the NewsItem constructor, check the path
authorZac Medico <zmedico@gentoo.org>
Wed, 12 Nov 2008 18:43:19 +0000 (18:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 12 Nov 2008 18:43:19 +0000 (18:43 -0000)
inside NewsManager.updateItems() before the NewsItem constructor is called.

svn path=/main/trunk/; revision=11863

pym/portage/news.py

index 9d51d8baf7a3364a10975081ec20d98b630fc722..57db9ff41fb6b7b2b1a216d23d57f517983d5380 100644 (file)
@@ -82,11 +82,11 @@ class NewsManager(object):
                for itemid in news:
                        if itemid in skiplist:
                                continue
-                       try:
-                               filename = os.path.join(path, itemid, itemid + "." + self.language_id + ".txt")
-                               item = NewsItem(filename, itemid)
-                       except (TypeError):
+                       filename = os.path.join(path, itemid,
+                               itemid + "." + self.language_id + ".txt")
+                       if not os.path.isfile(filename):
                                continue
+                       item = NewsItem(filename, itemid)
                        if item.isRelevant(profile=self._profile_path,
                                config=self.config, vardb=self.vdb):
                                updates.append(item)
@@ -169,8 +169,6 @@ class NewsItem(object):
                """ 
                For a given news item we only want if it path is a file.
                """
-               if not os.path.isfile(path):
-                       raise TypeError("%s is no regular file" % path)
                self.path = path
                self.name = name
                self._parsed = False