jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/430929 )

Change subject: [IMPR] use str.format method usability
......................................................................

[IMPR] use str.format method usability

use str.format instead of concating indexed variables

Change-Id: Ic1c053da3e6c0a53c663ba4d4e8bf6284789f469
---
M scripts/surnames_redirects.py
1 file changed, 6 insertions(+), 10 deletions(-)

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



diff --git a/scripts/surnames_redirects.py b/scripts/surnames_redirects.py
index ab19916..5fadd38 100755
--- a/scripts/surnames_redirects.py
+++ b/scripts/surnames_redirects.py
@@ -16,7 +16,7 @@
 Example: "python pwb.py surnames_redirects -start:B"
 """
 #
-# (C) Pywikibot team, 2017
+# (C) Pywikibot team, 2017-2018
 #
 # Distributed under the terms of the MIT license.
 #
@@ -64,26 +64,22 @@
         if self.getOption('surnames_last'):
             name_parts = name.split(', ')
             if len(name_parts) == 2 and len(name.split(' ')) <= 3:
-                possible_names.append(name_parts[1] + ' ' + name_parts[0])
+                possible_names.append('{1} {0}'.format(*name_parts))
         else:
             words = name.split()
             if len(words) == 2 and name == name.title():
-                possible_names.append(words[1] + ', ' + words[0])
+                possible_names.append('{1}, {0}'.format(*words))
             elif len(words) == 3:
                 # title may have at most one non-titlecased word
                 if len(SequenceMatcher(None, name,
                    name.title()).get_matching_blocks()) <= 3:
-                    possible_names.append(words[1] + ' ' +
-                                          words[2] + ', ' +
-                                          words[0])
-                    possible_names.append(words[2] + ', ' +
-                                          words[0] + ' ' +
-                                          words[1])
+                    possible_names.append('{1} {2}, {0}'.format(*words))
+                    possible_names.append('{2}, {0} {1}'.format(*words))

         for possible_name in possible_names:
             # append disambiguation inside parenthesis if there is one
             if len(split_title) == 2:
-                possible_name += ' (' + split_title[1]
+                possible_name += ' ({1}'.format(*split_title)

             new_page = pywikibot.Page(site, possible_name)
             if new_page.exists():

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1c053da3e6c0a53c663ba4d4e8bf6284789f469
Gerrit-Change-Number: 430929
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1...@gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
Pywikibot-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to