jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030595?usp=email )

Change subject: [IMPR] Show the replacements pairs if they are incomplete as 
user hint
......................................................................

[IMPR] Show the replacements pairs if they are incomplete as user hint

Bug: T364689
Change-Id: I360e76aed1258c39facf5dac90a6fb81f7ac670b
---
M scripts/replace.py
M tests/replacebot_tests.py
2 files changed, 13 insertions(+), 8 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/scripts/replace.py b/scripts/replace.py
index ea12617..e9f4db5 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -142,7 +142,7 @@
 the top of the help.
 """
 #
-# (C) Pywikibot team, 2004-2023
+# (C) Pywikibot team, 2004-2024
 #
 # Distributed under the terms of the MIT license.
 #
@@ -820,6 +820,8 @@
     """Handle -pairsfile argument.

     .. versionadded:: 7.0
+    .. versionchanged:: 9.2
+       replacement patterns are printed it they are incomplete.
     """
     if not filename:
         filename = pywikibot.input(
@@ -835,8 +837,8 @@
         return None

     if len(replacements) % 2:
-        pywikibot.error(
-            f'{filename} contains an incomplete pattern replacement pair.')
+        pywikibot.error(f'{filename} contains an incomplete pattern '
+                        f'replacement pair:\n{replacements}')
         return None

     # Strip BOM from first line
@@ -893,11 +895,13 @@

 
 def main(*args: str) -> None:  # noqa: C901
-    """
-    Process command line arguments and invoke bot.
+    """Process command line arguments and invoke bot.

     If args is an empty list, sys.argv is used.

+    .. versionchanged:: 9.2
+       replacement patterns are printed it they are incomplete.
+
     :param args: command line arguments
     """
     options = {}
@@ -976,7 +980,8 @@
         return

     if len(commandline_replacements) % 2:
-        pywikibot.error('Incomplete command line pattern replacement pair.')
+        pywikibot.error('Incomplete command line pattern replacement pair:\n'
+                        f'{commandline_replacements}')
         return

     commandline_replacements += file_replacements
diff --git a/tests/replacebot_tests.py b/tests/replacebot_tests.py
index 2237ba5..a1e7eaf 100755
--- a/tests/replacebot_tests.py
+++ b/tests/replacebot_tests.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 """Tests for the replace script and ReplaceRobot class."""
 #
-# (C) Pywikibot team, 2015-2023
+# (C) Pywikibot team, 2015-2024
 #
 # Distributed under the terms of the MIT license.
 #
@@ -109,7 +109,7 @@
         with empty_sites():
             self._run('foo')
             self.assertEqual([
-                'Incomplete command line pattern replacement pair.',
+                "Incomplete command line pattern replacement pair:\n['foo']",
             ], pywikibot.bot.ui.pop_output())

         # In the end no bots should've been created

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030595?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I360e76aed1258c39facf5dac90a6fb81f7ac670b
Gerrit-Change-Number: 1030595
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to