jenkins-bot has submitted this change and it was merged.

Change subject: [IMPR] use Bot.user_confirm()
......................................................................


[IMPR] use Bot.user_confirm()

- input_choice never returns a key not passed to the method.
  Checking undefined key is obsolete
- Also it is not necessary to pass 'n' key because it is passed
  with the end of the if statement

Change-Id: Ib3b22caefde66becf116d8cc97deef5c28fbc212
---
M scripts/movepages.py
M scripts/protect.py
2 files changed, 8 insertions(+), 37 deletions(-)

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



diff --git a/scripts/movepages.py b/scripts/movepages.py
index b276b9c..78c62bf 100755
--- a/scripts/movepages.py
+++ b/scripts/movepages.py
@@ -34,7 +34,7 @@
 #
 # (C) Leonardo Gregianin, 2006
 # (C) Andreas J. Schwab, 2007
-# (C) Pywikibot team, 2006-2014
+# (C) Pywikibot team, 2006-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -109,20 +109,8 @@
         if self.getOption('prefix'):
             newPageTitle = (u'%s%s' % (self.getOption('prefix'), pagetitle))
         if self.getOption('prefix') or self.appendAll or self.regexAll:
-            if not self.getOption('always'):
-                choice2 = pywikibot.input_choice(
-                    u'Change the page title to "%s"?' % newPageTitle,
-                    [('yes', 'y'), ('no', 'n'), ('all', 'a')])
-                if choice2 == 'y':
-                    self.moveOne(page, newPageTitle)
-                elif choice2 == 'a':
-                    self.options['always'] = True
-                    self.moveOne(page, newPageTitle)
-                elif choice2 == 'n':
-                    pass
-                else:
-                    self.treat(page)
-            else:
+            if self.user_confirm('Change the page title to "%s"?'
+                                 % newPageTitle):
                 self.moveOne(page, newPageTitle)
         else:
             choice = pywikibot.input_choice(u'What do you want to do?',
@@ -153,10 +141,6 @@
                 elif choice2 == 'a':
                     self.appendAll = True
                     self.moveOne(page, newPageTitle)
-                elif choice2 == 'n':
-                    pass
-                else:
-                    self.treat(page)
             elif choice == 'r':
                 searchPattern = pywikibot.input(u'Enter the search pattern:')
                 self.replacePattern = pywikibot.input(
@@ -183,14 +167,6 @@
                 elif choice2 == 'a':
                     self.regexAll = True
                     self.moveOne(page, newPageTitle)
-                elif choice2 == 'n':
-                    pass
-                else:
-                    self.treat(page)
-            elif choice == 'n':
-                pass
-            else:
-                self.treat(page)
 
 
 def main(*args):
diff --git a/scripts/protect.py b/scripts/protect.py
index 01e2dc4..222f19e 100755
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -46,7 +46,7 @@
 # Written by https://it.wikisource.org/wiki/Utente:Qualc1
 # Created by modifying delete.py
 #
-# (C) Pywikibot team, 2008-2015
+# (C) Pywikibot team, 2008-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -99,15 +99,10 @@
         the protections using this function.
         """
         self.current_page = page
-        if not self.getOption('always'):
-            choice = pywikibot.input_choice(
-                u'Do you want to change the protection level of %s?'
-                % page.title(asLink=True, forceInterwiki=True),
-                [('yes', 'y'), ('No', 'n'), ('all', 'a')], 'n')
-            if choice == 'n':
-                return
-            elif choice == 'a':
-                self.options['always'] = True
+        if not self.user_confirm(
+                'Do you want to change the protection level of %s?'
+                % page.title(asLink=True, forceInterwiki=True)):
+            return
         applicable = page.applicable_protections()
         protections = dict(
             prot for prot in self.protections.items() if prot[0] in applicable)

-- 
To view, visit https://gerrit.wikimedia.org/r/270311
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib3b22caefde66becf116d8cc97deef5c28fbc212
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: Ricordisamoa <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to