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

Change subject: [IMPR] Simplify space replacement
......................................................................


[IMPR] Simplify space replacement

- use re.sub to replace multiple spaces by a single space instead of
  using a loop

Change-Id: I68a03dbc944cdc1721d42c5489cee3b868836264
---
M pywikibot/page.py
1 file changed, 1 insertion(+), 2 deletions(-)

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



diff --git a/pywikibot/page.py b/pywikibot/page.py
index 93c36f5..be6170b 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4984,8 +4984,7 @@
         # Replace underscores by spaces
         t = t.replace(u"_", u" ")
         # replace multiple spaces with a single space
-        while u"  " in t:
-            t = t.replace(u"  ", u" ")
+        t = re.sub(' {2,}', ' ', t)
         # Strip spaces at both ends
         t = t.strip()
         # Remove left-to-right and right-to-left markers.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I68a03dbc944cdc1721d42c5489cee3b868836264
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.w...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to