[Pywikipedia-l] SVN: [4769] trunk/pywikipedia

rotem at svn.wikimedia.org rotem at svn.wikimedia.org
Fri Dec 28 16:47:34 UTC 2007


Revision: 4769
Author:   rotem
Date:     2007-12-28 16:47:34 +0000 (Fri, 28 Dec 2007)

Log Message:
-----------
Avoiding a problematic parsing of the content if there are no entries in the category, using the message category-empty. Adding a TODO note to check behavior for versions in which category-empty does not exist. Also fixing a problem in a message.

Modified Paths:
--------------
    trunk/pywikipedia/category.py
    trunk/pywikipedia/catlib.py

Modified: trunk/pywikipedia/category.py
===================================================================
--- trunk/pywikipedia/category.py	2007-12-28 16:45:50 UTC (rev 4768)
+++ trunk/pywikipedia/category.py	2007-12-28 16:47:34 UTC (rev 4769)
@@ -412,7 +412,7 @@
                 if oldMovedTalk is not None:
                     oldMovedTalk.delete(reason, confirm)
             else:
-                wikipedia.output('Couldn\'t delete %s - not empty.' % (self.oldCat.title(), self.newCatTitle))
+                wikipedia.output('Couldn\'t delete %s - not empty.' % self.oldCat.title())
 
 class CategoryListifyRobot:
     '''

Modified: trunk/pywikipedia/catlib.py
===================================================================
--- trunk/pywikipedia/catlib.py	2007-12-28 16:45:50 UTC (rev 4768)
+++ trunk/pywikipedia/catlib.py	2007-12-28 16:47:34 UTC (rev 4769)
@@ -197,12 +197,19 @@
                     ibegin = txt.index('<div id="mw-pages">')
                     skippedCategoryDescription = True
                 except ValueError:
-                    try:
-                        ibegin = txt.index('<!-- start content -->') # does not work for cats without text
-                        skippedCategoryDescription = False
-                    except ValueError:
-                        wikipedia.output("\nCategory page detection is not bug free. Please report this error!")
-                        raise
+                    if self.site().has_mediawiki_message('category-empty') and self.site().mediawiki_message('category-empty') in txt:
+                        # No articles or subcategories
+                        return
+                    else:
+                        try:
+                            ibegin = txt.index('<!-- start content -->') # does not work for cats without text
+                            # TODO: This parses category text and may think they are
+                            # pages in category! Check for versions without the message
+                            # "category-empty".
+                            skippedCategoryDescription = False
+                        except ValueError:
+                            wikipedia.output("\nCategory page detection is not bug free. Please report this error!")
+                            raise
             # index where article listing ends
             try:
                 iend = txt.index('<div class="printfooter">')





More information about the Pywikipedia-l mailing list