http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10353
Revision: 10353 Author: drtrigon Date: 2012-06-13 09:10:13 +0000 (Wed, 13 Jun 2012) Log Message: ----------- follow-up; enhance r9909 and r10174 to non-API calls
Modified Paths: -------------- trunk/pywikipedia/config.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/config.py =================================================================== --- trunk/pywikipedia/config.py 2012-06-12 16:46:30 UTC (rev 10352) +++ trunk/pywikipedia/config.py 2012-06-13 09:10:13 UTC (rev 10353) @@ -476,7 +476,7 @@ # 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'] + 'emailuser', 'submit'] # 'submit' is for non-API
# How many pages should be put to a queue in asynchroneous mode. # If maxsize is <= 0, the queue size is infinite.
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2012-06-12 16:46:30 UTC (rev 10352) +++ trunk/pywikipedia/wikipedia.py 2012-06-13 09:10:13 UTC (rev 10353) @@ -5727,6 +5727,15 @@ body of the response.
""" + if ('action' in predata) and pywikibot.simulate and \ + (predata['action'] in pywikibot.config.actions_to_block): + pywikibot.output(u'\03{lightyellow}SIMULATION: %s action blocked.\03{default}'%\ + predata['action']) + import StringIO + f_dummy = StringIO.StringIO() + f_dummy.__dict__.update({u'code': 0, u'msg': u''}) + return f_dummy, u'' + data = self.urlEncode(predata) try: if cookies: @@ -8095,9 +8104,6 @@ config.cosmetic_changes = not config.cosmetic_changes 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') simulate = True # global debug option for development purposes. Normally does nothing. elif arg == '-debug': @@ -8183,7 +8189,7 @@ settings and restrictions are untouched.
-simulate Disables writing to the server. Useful for testing - and debugging of new code. (API only) + and debugging of new code. '''# % moduleName output(globalHelp, toStdout=True) try:
pywikipedia-svn@lists.wikimedia.org