Revision: 8047 Author: xqt Date: 2010-04-01 12:34:38 +0000 (Thu, 01 Apr 2010)
Log Message: ----------- use isCategoryRedirect() method
Modified Paths: -------------- trunk/pywikipedia/cfd.py
Modified: trunk/pywikipedia/cfd.py =================================================================== --- trunk/pywikipedia/cfd.py 2010-04-01 11:33:49 UTC (rev 8046) +++ trunk/pywikipedia/cfd.py 2010-04-01 12:34:38 UTC (rev 8047) @@ -7,8 +7,9 @@ Syntax: python cfd.py
""" - +# # (C) Ben McIlwain, 2008 +# (C) Pywikipedia bot team, 2009-2010 # # Distributed under the terms of the MIT license.
@@ -19,12 +20,6 @@ # The locateion of the CFD working page. cfdPage = 'Wikipedia:Categories for discussion/Working'
- -# A list of templates that signify that a category is redirected. -# If the category is redirect, we do NOT want to move articles to it. -# The safest thing to do here is abort and wait for human intervention. -redirTemplates = ['Category redirect', 'Categoryredirect', 'CR', 'Catredirect', 'Seecat', 'Cat redirect'] - # Regular expression declarations # See the en-wiki CFD working page at [[Wikipedia:Categories for discussion/Working]] # to see how these work in context. To get this bot working on other wikis you will @@ -97,7 +92,12 @@ summary = "Robot - Speedily moving category " + src + " to " + dest + " per [[WP:CFD|CFD]]." else: continue - if categoryIsRedirect(dest): + # If the category is redirect, we do NOT want to move articles to + # it. The safest thing to do here is abort and wait for human + # intervention. + destpage = wikipedia.Page( + wikipedia.getSite(), dest, defaultNamespace=14) + if destpage.isCategoryRedirect(): summary = 'CANCELED. Destination is redirect: ' + summary wikipedia.output(summary, toStdout=True) robot = None @@ -126,16 +126,6 @@ summary = "" robot = None
-# Returns true if the category is a redirected category, meaning we should -# NOT run the bot and instead let humans handle the exception. -def categoryIsRedirect(pageTitle): - page = wikipedia.Page(wikipedia.getSite(), "Category:" + pageTitle) - templates = page.templates(get_redirect=True) - for redirTemplate in redirTemplates: - if redirTemplate in templates: - return True - return False - # This function grabs the wiki source of a category page and attempts to # extract a link to the CFD per-day discussion page from the CFD template. # If the CFD template is not there, it will return the value of the second
pywikipedia-svn@lists.wikimedia.org