jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT/FIX] Replace: Explicitly allow userinput
......................................................................
[FEAT/FIX] Replace: Explicitly allow userinput
If replacements are defined before it shouldn't ask the user for any
more except when explicitly allowing userinput with '-manualinput'.
This fixes a problem that when -fix was provided it couldn't be
automated because it still asked if manual inputs are requested. This
changes the default behavior a bit, because previously manual input was
enabled when replacements via the command line were defined. But it
doesn't make sense that -manualinput is only required when using -fix.
This actually enables the bot to run automatically without user
interference using command line replacements and still allows the user
to specify replacements via the normal input.
Also removed explicit concatenation of two static strings and updated
documentation that -fix can now be used together with other parameters
like -nocase or additional replacements.
Change-Id: I199ed9e070b59424cb7251cc98ffd0a7ceff5b3f
---
M scripts/replace.py
1 file changed, 19 insertions(+), 18 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
index b5e1a2a..c13d421 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -64,8 +64,11 @@
-fix:XYZ Perform one of the predefined replacements tasks, which are
given in the dictionary 'fixes' defined inside the files
fixes.py and user-fixes.py.
- The -regex and -nocase argument and given replacements will
- be ignored if you use -fix.
+
+-manualinput Request manual replacements via the command line input even
+ if replacements are already defined. If this option is set
+ (or no replacements are defined via -fix or the arguments)
+ it'll ask for additional replacements at start.
&fixes-help;
@@ -692,6 +695,8 @@
# Between a regex and another (using -fix) sleep some time (not to waste
# too much CPU
sleep = None
+ # Request manual replacements even if replacements are already defined
+ manual_input = False
# Read commandline parameters.
@@ -746,6 +751,8 @@
edit_summary = arg[9:]
elif arg.startswith('-allowoverlap'):
allowoverlap = True
+ elif arg.startswith('-manualinput'):
+ manual_input = True
else:
commandline_replacements.append(arg)
@@ -753,20 +760,14 @@
if (len(commandline_replacements) % 2):
raise pywikibot.Error('require even number of replacements.')
- if not commandline_replacements:
- if fixes_set:
- manual = pywikibot.input_yn('Replacements via -fix: set. Apply '
- 'also manual replacements?',
default=False)
- else:
- manual = True
- if manual:
- old = pywikibot.input(u'Please enter the text that should be
replaced:')
- while old:
- new = pywikibot.input(u'Please enter the new text:')
- commandline_replacements += [old, new]
- old = pywikibot.input(
- u'Please enter another text that should be replaced,' +
- u'\nor press Enter to start:')
+ if not(commandline_replacements or fixes_set) or manual_input:
+ old = pywikibot.input(u'Please enter the text that should be replaced:')
+ while old:
+ new = pywikibot.input(u'Please enter the new text:')
+ commandline_replacements += [old, new]
+ old = pywikibot.input(
+ 'Please enter another text that should be replaced,'
+ '\nor press Enter to start:')
single_summary = None
for i in range(0, len(commandline_replacements), 2):
@@ -789,8 +790,8 @@
pywikibot.output('If a summary is defined for the fix, this '
'default summary won\'t be applied.')
edit_summary = pywikibot.input(
- u'Press Enter to use this automatic message, or enter a ' +
- u'description of the\nchanges your bot will make:')
+ 'Press Enter to use this automatic message, or enter a '
+ 'description of the\nchanges your bot will make:')
# Perform one of the predefined actions.
for fix in fixes_set:
--
To view, visit
https://gerrit.wikimedia.org/r/180788
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I199ed9e070b59424cb7251cc98ffd0a7ceff5b3f
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>