jenkins-bot has submitted this change and it was merged.
Change subject: Change: Unify name of parameters -pairs and -replacementfile in scripts ......................................................................
Change: Unify name of parameters -pairs and -replacementfile in scripts
Modify replace and movepages scripts to unify -pairs and -replacementfile parameters. Change replacebot_tests.py to reflect this change.
Bug: T117176 Change-Id: I8148e04e678b9eb03e37e644bbd362e7751c027a --- M scripts/movepages.py M scripts/replace.py M tests/replacebot_tests.py 3 files changed, 24 insertions(+), 10 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/movepages.py b/scripts/movepages.py index bf07c1b..0a1174b 100755 --- a/scripts/movepages.py +++ b/scripts/movepages.py @@ -26,9 +26,9 @@ -summary Prompt for a custom summary, bypassing the predefined message texts. Argument can also be given as "-summary:XYZ".
--pairs Read pairs of file names from a file. The file must be in a +-pairsfile Read pairs of file names from a file. The file must be in a format [[frompage]] [[topage]] [[frompage]] [[topage]] ... - Argument can also be given as "-pairs:filename" + Argument can also be given as "-pairsfile:filename"
""" # @@ -47,6 +47,8 @@
import pywikibot
+from pywikibot.exceptions import ArgumentDeprecationWarning +from pywikibot.tools import issue_deprecation_warning from pywikibot import i18n, pagegenerators
from pywikibot.bot import MultipleSitesBot @@ -192,11 +194,16 @@
for arg in local_args: if arg.startswith('-pairs'): - if len(arg) == len('-pairs'): + issue_deprecation_warning( + '-pairs', + '-pairsfile', + 2, ArgumentDeprecationWarning) + elif arg.startswith('-pairsfile'): + if len(arg) == len('-pairsfile'): filename = pywikibot.input( u'Enter the name of the file containing pairs:') else: - filename = arg[len('-pairs:'):] + filename = arg[len('-pairsfile:'):] oldName1 = None for page in pagegenerators.TextfilePageGenerator(filename): if oldName1: diff --git a/scripts/replace.py b/scripts/replace.py index 0941a59..7e3f0d9 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -75,9 +75,9 @@ (or no replacements are defined via -fix or the arguments) it'll ask for additional replacements at start.
--replacementfile Lines from the given file name(s) will be read as replacement +-pairsfile Lines from the given file name(s) will be read as replacement arguments. i.e. a file containing lines "a" and "b", used as - python pwb.py replace -page:X -replacementfile:file c d + python pwb.py replace -page:X -pairsfile:file c d will replace 'a' with 'b' and 'c' with 'd'.
-always Don't prompt you for each replacement @@ -152,6 +152,8 @@
import pywikibot
+from pywikibot.exceptions import ArgumentDeprecationWarning +from pywikibot.tools import issue_deprecation_warning from pywikibot import i18n, textlib, pagegenerators, Bot
from pywikibot import editor as editarticle @@ -917,14 +919,19 @@ elif arg.startswith('-manualinput'): manual_input = True elif arg.startswith('-replacementfile'): + issue_deprecation_warning( + '-replacementfile', + '-pairsfile', + 2, ArgumentDeprecationWarning) + elif arg.startswith('-pairsfile'): if len(commandline_replacements) % 2: replacement_file_arg_misplaced = True
- if arg == '-replacementfile': + if arg == '-pairsfile': replacement_file = pywikibot.input( u'Please enter the filename to read replacements from:') else: - replacement_file = arg[len('-replacementfile:'):] + replacement_file = arg[len('-pairsfile:'):] else: commandline_replacements.append(arg)
@@ -936,7 +943,7 @@
if replacement_file_arg_misplaced: pywikibot.error( - '-replacementfile used between a pattern replacement pair.') + '-pairsfile used between a pattern replacement pair.') return False
if replacement_file: diff --git a/tests/replacebot_tests.py b/tests/replacebot_tests.py index 4bbcb74..e7181e7 100644 --- a/tests/replacebot_tests.py +++ b/tests/replacebot_tests.py @@ -98,7 +98,7 @@ def test_invalid_replacements(self): """Test invalid command line replacement configurations.""" # old and new need to be together - self.assertFalse(self._run('foo', '-replacementfile:/dev/null', 'bar')) + self.assertFalse(self._run('foo', '-pairsfile:/dev/null', 'bar')) # only old provided self.assertFalse(self._run('foo'))
pywikibot-commits@lists.wikimedia.org