Use param "-always" to run without any interactiv requests

This commit is contained in:
2015-11-07 16:50:26 +01:00
parent f05889a15b
commit 0a49b27d7f

View File

@@ -46,7 +46,7 @@ class Charts:
Class for handling chart lists Class for handling chart lists
""" """
def __init__( self, generator, dry ): def __init__( self, generator, always, dry ):
""" """
Constructor. Constructor.
@@ -60,6 +60,7 @@ class Charts:
self.generator = generator self.generator = generator
self.dry = dry self.dry = dry
self.always = always
# Set the edit summary message # Set the edit summary message
self.site = pywikibot.Site() self.site = pywikibot.Site()
@@ -119,7 +120,7 @@ class Charts:
pywikibot.showDiff(page.get(), text) pywikibot.showDiff(page.get(), text)
pywikibot.output(u'Comment: %s' % comment) pywikibot.output(u'Comment: %s' % comment)
if not self.dry: if not self.dry:
if True or pywikibot.input_yn( if self.always or pywikibot.input_yn(
u'Do you want to accept these changes?', u'Do you want to accept these changes?',
default=False, automatic_quit=False): default=False, automatic_quit=False):
try: try:
@@ -416,10 +417,15 @@ def main(*args):
# what would have been changed. # what would have been changed.
dry = False dry = False
# If always is True, bot won't ask for confirmation of edit (automode)
always = False
# Parse command line arguments # Parse command line arguments
for arg in local_args: for arg in local_args:
if arg.startswith("-dry"): if arg.startswith("-dry"):
dry = True dry = True
elif arg.startswith("-always"):
always = True
else: else:
genFactory.handleArg(arg) genFactory.handleArg(arg)
@@ -429,7 +435,7 @@ def main(*args):
# The preloading generator is responsible for downloading multiple # The preloading generator is responsible for downloading multiple
# pages from the wiki simultaneously. # pages from the wiki simultaneously.
gen = pagegenerators.PreloadingGenerator(gen) gen = pagegenerators.PreloadingGenerator(gen)
bot = Charts(gen, dry) bot = Charts(gen, always, dry)
bot.run() bot.run()
else: else:
pywikibot.showHelp() pywikibot.showHelp()