Revision: 5136
Author: filnik
Date: 2008-03-16 12:30:29 +0000 (Sun, 16 Mar 2008)
Log Message:
-----------
Adding the option to select the namespace of the protected pages, added an example
Modified Paths:
--------------
trunk/pywikipedia/blockpageschecker.py
Modified: trunk/pywikipedia/blockpageschecker.py
===================================================================
--- trunk/pywikipedia/blockpageschecker.py 2008-03-16 11:45:10 UTC (rev 5135)
+++ trunk/pywikipedia/blockpageschecker.py 2008-03-16 12:30:29 UTC (rev 5136)
@@ -20,8 +20,9 @@
Argument can also be given as "-page:pagetitle". You can
give this parameter multiple times to edit multiple pages.
--protectedpages Check all the blocked pages (useful when you have not categories
- or when you have problems with them.
+-protectedpages: Check all the blocked pages (useful when you have not categories
+ or when you have problems with them. (add the namespace after
":" where
+ you want to check - default: 0)
Furthermore, the following command line parameters are supported:
@@ -46,6 +47,8 @@
python blockpageschecker.py -cat:Geography -always
+python blockpageschecker.py -debug -protectedpages:4
+
"""
#
# (C) Monobi a.k.a. Wikihermit, 2007
@@ -177,9 +180,10 @@
return ('autoconfirmed-move', catchRegex)
return ('editable', r'\A\n')
-def ProtectedPagesData():
+def ProtectedPagesData(namespace = 0):
""" Yield all the pages blocked, using Special:ProtectedPages
"""
- url =
'/w/index.php?title=Speciale%3AProtectedPages&namespace=0&type=edit&level=0&size='
+ # Avoid problems of encoding and stuff like that, let it divided please
+ url = '/w/index.php?title=Speciale%3AProtectedPages' +
'&namespace=%s&type=edit&level=0&size=' % namespace
site = wikipedia.getSite()
parser_text = site.getUrl(url)
while 1:
@@ -225,9 +229,9 @@
status = '%s' % level
return status
-def ProtectedPages():
+def ProtectedPages(namespace = 0):
""" Return only the wiki page object and not the tuple with all the
data as above """
- for data in ProtectedPagesData():
+ for data in ProtectedPagesData(namespace):
yield wikipedia.Page(wikipedia.getSite(), data[0])
def debugQuest(site, page):
@@ -269,8 +273,11 @@
moveBlockCheck = True
elif arg == '-debug':
debug = True
- elif arg == '-protectedpages':
- generator = ProtectedPages()
+ elif arg.startswith('-protectedpages'):
+ if len(arg) == 15:
+ generator = ProtectedPages(0)
+ else:
+ generator = ProtectedPages(int(arg[16:]))
elif arg.startswith('-page'):
if len(arg) == 5:
generator = [wikipedia.Page(wikipedia.getSite(),
wikipedia.input(u'What page do you want to use?'))]
Show replies by date