Revision: 7098 Author: purodha Date: 2009-07-26 23:13:57 +0000 (Sun, 26 Jul 2009)
Log Message: ----------- Add -redirectonly page generator.
Modified Paths: -------------- trunk/pywikipedia/pagegenerators.py
Modified: trunk/pywikipedia/pagegenerators.py =================================================================== --- trunk/pywikipedia/pagegenerators.py 2009-07-26 14:18:13 UTC (rev 7097) +++ trunk/pywikipedia/pagegenerators.py 2009-07-26 23:13:57 UTC (rev 7098) @@ -137,6 +137,15 @@ -recentchanges Work on new and edited pages returned by [[Special:Recentchanges]]. Can also be given as "-recentchanges:n" where n is the number of pages to be returned, else 100 pages are returned. + +-redirectonly Work on redirect pages only, not their target pages. + The robot goes alphabetically through all redirect pages + on the wiki, starting at the named page. The + argument can also be given as "-redirectonly:pagetitle". + + You can also include a namespace. For example, + "-redirectonly:Template:!" will make the bot work on + all redirect pages in the template namespace. """
@@ -1058,6 +1067,16 @@ firstPageTitle).titleWithoutNamespace() gen = AllpagesPageGenerator(firstPageTitle, namespace, includeredirects=False) + elif arg.startswith('-redirectonly'): + firstPageTitle = arg[15:] + if not firstPageTitle: + firstPageTitle = wikipedia.input( + u'At which page do you want to start?') + namespace = wikipedia.Page(site, firstPageTitle).namespace() + firstPageTitle = wikipedia.Page(site, + firstPageTitle).titleWithoutNamespace() + gen = AllpagesPageGenerator(firstPageTitle, namespace, + includeredirects='only') elif arg.startswith('-prefixindex'): prefix = arg[13:] namespace = None
pywikipedia-svn@lists.wikimedia.org