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.