Xqt has submitted this change and it was merged.
Change subject: remove obsolete dry option for constructor,
......................................................................
remove obsolete dry option for constructor,
-dry and older debug option has been removed when -simulate became a global option.
- replace setAction() with self.comment for put() parameter
Change-Id: I758a8f6c353e396965b255b754be190181eb986e
---
M piper.py
1 file changed, 28 insertions(+), 31 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/piper.py b/piper.py
index 90c0ca2..cd9f870 100644
--- a/piper.py
+++ b/piper.py
@@ -32,7 +32,7 @@
"""
#
-# (C) Pywikipedia bot team, 2008-2010
+# (C) Pywikipedia bot team, 2008-2013
#
# Distributed under the terms of the MIT license.
#
@@ -51,6 +51,7 @@
'¶ms;': pagegenerators.parameterHelp
}
+
class PiperBot:
# Edit summary message that should be used.
# NOTE: Put a good description here, and add translations, if possible!
@@ -62,25 +63,22 @@
'nl': u'Bot: paginatekst door %s geleid'
}
- def __init__(self, generator, dry, filters, always):
+ def __init__(self, generator, filters, always):
"""
Constructor. Parameters:
* generator - The page generator that determines on which pages
to work on.
- * dry - If True, doesn't do any real changes, but only shows
- what would have been changed.
* always - If True, don't prompt for changes
"""
self.generator = generator
- self.dry = dry
self.always = always
self.filters = filters
+ self.command = None
def run(self):
# Set the edit summary message
- pipes = ', '.join(self.filters)
- pywikibot.setAction(pywikibot.translate(pywikibot.getSite(), self.msg)
- % pipes)
+ s = ', '.join(self.filters)
+ self.command = pywikibot.translate(pywikibot.getSite(), self.msg) % s
for page in self.generator:
self.treat(page)
@@ -136,28 +134,27 @@
pywikibot.output(u"\n\n>>> %s <<<" %
page.title())
# show what was changed
pywikibot.showDiff(page.get(), text)
- if not self.dry:
- if not self.always:
- choice = pywikibot.inputChoice(
- u'Do you want to accept these changes?',
- ['Yes', 'No'], ['y', 'N'],
'N')
- else:
- choice = 'y'
- if choice == 'y':
- try:
- # Save the page
- page.put(text)
- except pywikibot.LockedPage:
- pywikibot.output(u"Page %s is locked; skipping."
- % page.title(asLink=True))
- except pywikibot.EditConflict:
- pywikibot.output(
- u'Skipping %s because of edit conflict'
- % (page.title()))
- except pywikibot.SpamfilterError, error:
- pywikibot.output(
- u'Cannot change %s because of spam blacklist entry
%s'
- % (page.title(), error.url))
+ if not self.always:
+ choice = pywikibot.inputChoice(
+ u'Do you want to accept these changes?',
+ ['Yes', 'No'], ['y', 'N'],
'N')
+ else:
+ choice = 'y'
+ if choice == 'y':
+ try:
+ # Save the page
+ page.put(text, self.comment)
+ except pywikibot.LockedPage:
+ pywikibot.output(u"Page %s is locked; skipping."
+ % page.title(asLink=True))
+ except pywikibot.EditConflict:
+ pywikibot.output(
+ u'Skipping %s because of edit conflict'
+ % (page.title()))
+ except pywikibot.SpamfilterError, error:
+ pywikibot.output(
+ u'Cannot change %s because of spam blacklist entry %s'
+ % (page.title(), error.url))
def main():
@@ -200,7 +197,7 @@
# The preloading generator is responsible for downloading multiple
# pages from the wiki simultaneously.
gen = pagegenerators.PreloadingGenerator(gen)
- bot = PiperBot(gen, pywikibot.simulate, filters, always)
+ bot = PiperBot(gen, filters, always)
bot.run()
else:
pywikibot.showHelp()
--
To view, visit
https://gerrit.wikimedia.org/r/91407
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I758a8f6c353e396965b255b754be190181eb986e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot