jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1323970?usp=email )
Change subject: cosmetic_changes: Simplify final returns
......................................................................
cosmetic_changes: Simplify final returns
Return the final replaceExcept() calls directly in five cosmetic cleanup
methods.
Change-Id: I485d89d9a0fd187abb1ceb9c748a1c1a46602327
---
M pywikibot/cosmetic_changes.py
1 file changed, 6 insertions(+), 12 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
JJMC89: Looks good to me, approved
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index dfe0338..4242ad0 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -956,14 +956,13 @@
text = textlib.replaceExcept(text, r'(?i)<hr ([^>/]+?)>',
r'<hr \1 />',
exceptions)
+ # TODO: maybe we can make the bot replace <p> tags with \r\n's.
# a header where only spaces are in the same line
- text = textlib.replaceExcept(
+ return textlib.replaceExcept(
text,
r'(?i)(?<=[\r\n]) *<h([1-7])> *([^<]+?) *</h\1> *(?=[\r\n])',
replace_header,
exceptions)
- # TODO: maybe we can make the bot replace <p> tags with \r\n's.
- return text
def fixReferences(self, text: str) -> str:
"""Fix references tags."""
@@ -978,10 +977,9 @@
text = textlib.replaceExcept(text,
r'(?i)(<ref\s*/>|<ref *>\s*</ref>)',
r'', exceptions)
- text = textlib.replaceExcept(text,
+ return textlib.replaceExcept(text,
r'(?i)<ref\s+([^>]+?)\s*>\s*</ref>',
r'<ref \1/>', exceptions)
- return text
def fixStyle(self, text: str) -> str:
"""Convert prettytable to wikitable class."""
@@ -1019,10 +1017,9 @@
text = textlib.replaceExcept(text, r'(\d)\s*(?: )?[º°]([CF])',
r'\1 °\2', exceptions,
site=self.site)
- text = textlib.replaceExcept(text, 'º([CF])', '°' + r'\1',
+ return textlib.replaceExcept(text, 'º([CF])', '°' + r'\1',
exceptions,
site=self.site)
- return text
def fixArabicLetters(self, text: str) -> str:
"""Fix Arabic and Persian letters."""
@@ -1064,11 +1061,9 @@
site=self.site)
text = textlib.replaceExcept(text, 'ك', 'ک', exceptions,
site=self.site)
- text = textlib.replaceExcept(text, '[ىي]', 'ی', exceptions,
+ return textlib.replaceExcept(text, '[ىي]', 'ی', exceptions,
site=self.site)
- return text
-
def commonsfiledesc(self, text: str) -> str:
"""Clean up file descriptions on Wikimedia Commons.
@@ -1128,12 +1123,11 @@
r'([\r\n]|^)\=\= *{{int:filedesc}} *\=\=(?:[\r\n ]*)\=\= *'
r'{{int:filedesc}} *\=\=',
r'\1== {{int:filedesc}} ==', exceptions, True)
- text = textlib.replaceExcept(
+ return textlib.replaceExcept(
text,
r'([\r\n]|^)\=\= *{{int:license-header}} *\=\=(?:[\r\n ]*)'
r'\=\= *{{int:license-header}} *\=\=',
r'\1== {{int:license-header}} ==', exceptions, True)
- return text
def fix_ISBN(self, text: str) -> str:
"""Hyphenate ISBN numbers."""
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1323970?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I485d89d9a0fd187abb1ceb9c748a1c1a46602327
Gerrit-Change-Number: 1323970
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]