jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/926656 )

Change subject: [IMPR] simplifying complex logical expression in 
fixing_redirects.py
......................................................................

[IMPR] simplifying complex logical expression in fixing_redirects.py

also use f-sting literals

Change-Id: I6b1016b8628c0c926101f3bdf704e6da1c4fe158
---
M scripts/fixing_redirects.py
1 file changed, 22 insertions(+), 13 deletions(-)

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




diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index 30a2f66..ab13424 100755
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -17,7 +17,7 @@
 &params;
 """
 #
-# (C) Pywikibot team, 2004-2022
+# (C) Pywikibot team, 2004-2023
 #
 # Distributed under the terms of the MIT license.
 #
@@ -118,9 +118,8 @@
             else:
                 section = m['section']
             if section and target_page.section():
-                pywikibot.warning(
-                    'Source section {} and target section {} found. '
-                    'Skipping.'.format(section, target_page))
+                pywikibot.warning(f'Source section {section} and target '
+                                  f'section {target_page} found. Skipping.')
                 continue
             trailing_chars = m['linktrail']
             if trailing_chars:
@@ -138,8 +137,8 @@
             if new_page_title[0] == ':':
                 new_page_title = new_page_title[1:]

-            if ((new_page_title == link_text and not section)
-                    or self.opt.overwrite):
+            if new_page_title == link_text and not section \
+               or self.opt.overwrite:
                 newlink = f'[[{new_page_title}]]'
             # check if we can create a link with trailing characters instead of
             # a pipelink
@@ -149,11 +148,10 @@
                   and re.sub(re.compile(linktrail), '',
                              link_text[len(new_page_title):]) == ''
                   and not section):
-                newlink = '[[{}]]{}'.format(link_text[:len(new_page_title)],
-                                            link_text[len(new_page_title):])
+                length = len(new_page_title)
+                newlink = f'[[{link_text[:length]}]]{link_text[length:]}'
             else:
-                newlink = '[[{}{}|{}]]'.format(new_page_title,
-                                               section, link_text)
+                newlink = f'[[{new_page_title}{section}|{link_text}]]'
             text = text[:m.start()] + newlink + text[m.end():]
             continue
         return text
@@ -181,9 +179,9 @@
                 if section and not does_text_contain_section(target.text,
                                                              section):
                     pywikibot.warning(
-                        'Section #{} not found on page {}'
-                        .format(section, target.title(as_link=True,
-                                                      with_section=False)))
+                        f'Section #{section} not found on page '
+                        f'{target.title(as_link=True, with_section=False)}'
+                    )
                     target = None
 
         if target is not None \

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/926656
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: I6b1016b8628c0c926101f3bdf704e6da1c4fe158
Gerrit-Change-Number: 926656
Gerrit-PatchSet: 2
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