[Pywikipedia-l] SVN: [4738] trunk/pywikipedia/delete.py

rotem at svn.wikimedia.org rotem at svn.wikimedia.org
Thu Dec 20 07:19:30 UTC 2007


Revision: 4738
Author:   rotem
Date:     2007-12-20 07:19:29 +0000 (Thu, 20 Dec 2007)

Log Message:
-----------
A possibility not to delete pages in subcategories.

Modified Paths:
--------------
    trunk/pywikipedia/delete.py

Modified: trunk/pywikipedia/delete.py
===================================================================
--- trunk/pywikipedia/delete.py	2007-12-20 07:16:52 UTC (rev 4737)
+++ trunk/pywikipedia/delete.py	2007-12-20 07:19:29 UTC (rev 4738)
@@ -9,6 +9,7 @@
 
 -page:       Delete specified page
 -cat:        Delete all pages in the given category.
+-nosubcats:  Don't delete pages in the subcategories.
 -links:      Delete all pages linked from a given page.
 -file:       Delete all pages listed in a text file.
 -ref:        Delete all pages referring from a given page.
@@ -112,6 +113,7 @@
     always = False
     doSinglePage = False
     doCategory = False
+    deleteSubcategories = True
     doRef = False
     doLinks = False
     doImages = False
@@ -139,6 +141,8 @@
                 pageName = wikipedia.input(u'Enter the category to delete from:')
             else:
                 pageName = arg[len('-cat:'):]
+        elif arg.startswith('-nosubcats'):
+            deleteSubcategories = False
         elif arg.startswith('-links'):
             doLinks = True
             if len(arg) == len('-links'):
@@ -178,7 +182,7 @@
             summary = wikipedia.translate(mysite, msg_delete_category) % pageName
         ns = mysite.category_namespace()
         categoryPage = catlib.Category(mysite, ns + ':' + pageName)
-        gen = pagegenerators.CategorizedPageGenerator(categoryPage, recurse=True)
+        gen = pagegenerators.CategorizedPageGenerator(categoryPage, recurse = deleteSubcategories)
     elif doLinks:
         if not summary:
             summary = wikipedia.translate(mysite, msg_delete_links) % pageName





More information about the Pywikipedia-l mailing list