http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10174
Revision: 10174 Author: xqt Date: 2012-05-03 13:16:35 +0000 (Thu, 03 May 2012) Log Message: ----------- simulate actions_to_block is now user_configurable, follow-up for r10072
Modified Paths: -------------- trunk/pywikipedia/config.py trunk/pywikipedia/query.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py =================================================================== --- trunk/pywikipedia/config.py 2012-05-03 10:54:23 UTC (rev 10173) +++ trunk/pywikipedia/config.py 2012-05-03 13:16:35 UTC (rev 10174) @@ -464,11 +464,10 @@ retry_on_fail = True
# Defines what actions the bots are NOT allowed to do (e.g. 'edit') on wikipedia -# servers. Setting this to: -# actions_to_block = ['edit', 'watch', 'move', 'delete', 'undelete', 'protect'] -# allows simulation runs of bots to be carried out without changing any page on -# the server side. -actions_to_block = [] +# servers. Allows simulation runs of bots to be carried out without changing any +# page on the server side. This setting may be overridden in user_config.py. +actions_to_block = ['edit', 'watch', 'move', 'delete', 'undelete', 'protect', + 'emailuser']
# How many pages should be put to a queue in asynchroneous mode. # If maxsize is <= 0, the queue size is infinite.
Modified: trunk/pywikipedia/query.py =================================================================== --- trunk/pywikipedia/query.py 2012-05-03 10:54:23 UTC (rev 10173) +++ trunk/pywikipedia/query.py 2012-05-03 13:16:35 UTC (rev 10174) @@ -42,7 +42,8 @@ sysop=False, back_response=False): """Get data from the query api, and convert it into a data object """ - if ('action' in params) and (params['action'] in pywikibot.config.actions_to_block): + if ('action' in params) and pywikibot.simulate and \ + (params['action'] in pywikibot.config.actions_to_block): pywikibot.output(u'\03{lightyellow}SIMULATION: %s action blocked.\03{default}'%\ params['action']) jsontext_dummy = {params['action']: {u'result':u''}}
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2012-05-03 10:54:23 UTC (rev 10173) +++ trunk/pywikipedia/wikipedia.py 2012-05-03 13:16:35 UTC (rev 10174) @@ -7731,7 +7731,7 @@ args may be passed as an argument, thereby overriding sys.argv
""" - global default_code, default_family, verbose, debug + global default_code, default_family, verbose, debug, simulate # get commandline arguments if necessary if not args: args = sys.argv[1:] @@ -7776,9 +7776,9 @@ output(u'NOTE: option cosmetic_changes is %s\n' % config.cosmetic_changes) elif arg == '-simulate': if not getSite().has_api(): - raise NotImplementedError('-simulate option is implemented for API only') - config.actions_to_block = ['edit', 'watch', 'move', 'delete', - 'undelete', 'protect', 'emailuser'] + raise NotImplementedError( + '-simulate option is implemented for API only') + simulate = True # global debug option for development purposes. Normally does nothing. elif arg == '-debug': debug = True @@ -7877,6 +7877,7 @@ ui = uiModule.UI() verbose = 0 debug = False +simulate = False
# TEST for bug #3081100 unicode_error = __import__('unicodedata').normalize(
pywikipedia-svn@lists.wikimedia.org