Revision: 3967 Author: wikipedian Date: 2007-08-06 10:42:27 +0000 (Mon, 06 Aug 2007)
Log Message: ----------- experimental, unfinished: added a way to include a docstring from pagegenerators.py.
Modified Paths: -------------- trunk/pywikipedia/interwiki.py trunk/pywikipedia/pagegenerators.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/interwiki.py =================================================================== --- trunk/pywikipedia/interwiki.py 2007-08-06 10:41:41 UTC (rev 3966) +++ trunk/pywikipedia/interwiki.py 2007-08-06 10:42:27 UTC (rev 3967) @@ -10,6 +10,9 @@ original page will be automatically updated and the modified page uploaded.
This script understands various command-line arguments: + +&pagegenerators_help; + -force: do not ask permission to make "controversial" changes, like removing a language because none of the found alternatives actually exists. @@ -26,19 +29,6 @@ 20:, 30:, 50: Analogous to 10: with ca. 20, 30 and 50 languages cyril: Provides the hint for all languages that use the cyrillic alphabet
- -cat Work on all pages which are in a specific category. - Argument can also be given as "-cat:categoryname". - - -subcat Like -cat, but also includes pages in subcategories of the - given category. - Argument can also be given as "-subcat:categoryname". - - -ref Work on all pages that link to a certain page. - Argument can also be given as "-ref:referredpagetitle". - - -links Work on all pages that are linked from a certain page. - Argument can also be given as "-links:linkingpagetitle". - -new Work on the most recent new pages on the wiki
-same: looks over all 'serious' languages for the same title. @@ -62,9 +52,6 @@ you will go through the whole alphabet before any queries are performed!
- -file: used as -file:filename, read a list of pages to treat - from the named file - -confirm: ask for confirmation before any page is changed on the live wiki. Without this argument, additions and unambiguous modifications are made without confirmation. @@ -81,12 +68,6 @@
-nobacklink: switch off the backlink warnings
- -start: used as -start:title, specifies that the robot should - go alphabetically through all pages on the home wiki, - starting at the named page. If -start:title and -cat:category - are both added, go through category category, but start - alphabetically at pagename title instead of the beginning. - -number: used as -number:#, specifies that the robot should process that amount of pages and then stop. This is only useful in combination with -start. The default is not to stop. @@ -104,7 +85,7 @@ negative value, it is interpreted as a year BC. If the argument is simply given as -years, it will run from 1 through 2050. - + This implies -noredirect.
-noauto: Do not use the automatic translation feature for years and @@ -116,11 +97,10 @@ argument is simply given as -days, it will run from Jan 1 through Dec 31. E.g. for -days:9 it will run from Sep 1 through Dec 31. - + -skipfile: used as -skipfile:filename, skip all links mentioned in - the given file from the list generated by -start. This - does not work with -number! - + the given file. This does not work with -number! + -skipauto: use to skip all pages that can be translated automatically, like dates, centuries, months, etc.
@@ -153,7 +133,7 @@
-ignorefile: similar to -ignore, except that the pages are taken from the given file instead of the command line. - + -showpage when asking for hints, show the first bit of the text of the page always, rather than doing so only when being asked for (by typing '?'). Only useful in combination @@ -162,7 +142,7 @@
-localonly only work on the local wiki, not on other wikis in the family I have a login at - + -limittwo only update two pages - one in the local wiki (if loged-in), and one in the top available one. For example, if the local page has links to de and fr, @@ -180,7 +160,7 @@ (for example -whenneeded:3), in which case other languages will be changed if there are that number or more links to change or add - + -bracket only work on pages that have (in the home language) a bracket in their title. All other pages are skipped.
@@ -218,6 +198,7 @@ # __version__ = '$Id$' # + import sys, copy, re import time import codecs @@ -252,6 +233,10 @@ import wikipedia, config, pagegenerators, catlib import titletranslate, interwiki_graph
+docuReplacements = { + '&pagegenerators_help;': pagegenerators.parameterHelp +} + class SaveError(wikipedia.Error): """ An attempt to save a page with changed interwiki has failed.
Modified: trunk/pywikipedia/pagegenerators.py =================================================================== --- trunk/pywikipedia/pagegenerators.py 2007-08-06 10:41:41 UTC (rev 3966) +++ trunk/pywikipedia/pagegenerators.py 2007-08-06 10:42:27 UTC (rev 3967) @@ -6,10 +6,42 @@ that yields page objects on which other scripts can then work.
In general, there is no need to run this script directly. It can, however, -be run for testing purposes. +be run for testing purposes. It will then print the page titles to standard +output. + +These parameters are supported to specify which pages titles to print: + +¶ms; """ __version__='$Id$'
+parameterHelp = """ -cat Work on all pages which are in a specific category. + Argument can also be given as "-cat:categoryname". + + -subcat Like -cat, but also includes pages in subcategories of the + given category. + Argument can also be given as "-subcat:categoryname". + + -start: Specifies that the robot should go alphabetically through + all pages on the home wiki, starting at the named page. + Argument can also be given as "-subcat:pagetitle". + + -ref Work on all pages that link to a certain page. + Argument can also be given as "-ref:referredpagetitle". + + -links Work on all pages that are linked from a certain page. + Argument can also be given as "-links:linkingpagetitle". + + -file: used as -file:filename, read a list of pages to treat + from the named text file. + Page titles in the file must be enclosed with [[brackets]]. + Argument can also be given as "-file:filename".""" + +docuReplacements = { + '¶ms;': parameterHelp +} + + # Standard library imports import re, codecs, sys import threading, Queue
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2007-08-06 10:41:41 UTC (rev 3966) +++ trunk/pywikipedia/wikipedia.py 2007-08-06 10:42:27 UTC (rev 3967) @@ -4531,7 +4531,7 @@ except ValueError: # There was no \ in the module name, so presumably no problem pass globalHelp =u''' - + Global arguments available for all bots:
-lang:xx Set the language of the wiki you want to work on, overriding @@ -4558,8 +4558,13 @@ output(globalHelp) try: exec('import %s as module' % moduleName) - output(module.__doc__, 'utf-8') + helpText = module.__doc__.decode('utf-8') + if hasattr(module, 'docuReplacements'): + for key, value in module.docuReplacements.iteritems(): + helpText = helpText.replace(key, value) + output(helpText) except: + raise output(u'Sorry, no help available for %s' % moduleName)
page_put_queue = Queue.Queue()