http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9905
Revision: 9905 Author: drtrigon Date: 2012-02-17 13:47:49 +0000 (Fri, 17 Feb 2012) Log Message: ----------- debugging '-debug' enabled for clean_sandbox
Modified Paths: -------------- trunk/pywikipedia/clean_sandbox.py
Modified: trunk/pywikipedia/clean_sandbox.py =================================================================== --- trunk/pywikipedia/clean_sandbox.py 2012-02-17 13:29:07 UTC (rev 9904) +++ trunk/pywikipedia/clean_sandbox.py 2012-02-17 13:47:49 UTC (rev 9905) @@ -186,10 +186,12 @@ if (pos < 0) or (endpos == len(text)): pywikibot.output(u'The user sandbox is still clean or not set up, no change necessary.') else: - sandboxPage.put(text[:endpos], translatedMsg) + if not pywikibot.debug: + sandboxPage.put(text[:endpos], translatedMsg) pywikibot.output(u'Standard content was changed, user sandbox cleaned.') else: - sandboxPage.put(translatedContent, translatedMsg) + if not pywikibot.debug: + sandboxPage.put(translatedContent, translatedMsg) pywikibot.output(u'Standard content was changed, sandbox cleaned.') else: diff = minutesDiff(sandboxPage.editTime(), time.strftime("%Y%m%d%H%M%S", time.gmtime())) @@ -197,7 +199,8 @@ print sandboxPage.editTime(), time.strftime("%Y%m%d%H%M%S", time.gmtime()) #Is the last edit more than 5 minutes ago? if diff >= self.delay: - sandboxPage.put(translatedContent, translatedMsg) + if not pywikibot.debug: + sandboxPage.put(translatedContent, translatedMsg) else: #wait for the rest pywikibot.output(u'Sleeping for %d minutes.' % (self.delay-diff)) time.sleep((self.delay-diff)*60) @@ -234,6 +237,9 @@ pywikibot.showHelp('clean_sandbox') return
+ if pywikibot.debug: + pywikibot.output(u'\03{lightyellow}DEBUG: write actions blocked.\03{default}') + bot = SandboxBot(hours, no_repeat, delay, user) try: bot.run()