jenkins-bot has submitted this change and it was merged.
Change subject: Build lang prefixes list once in removeLanguageLinks() ......................................................................
Build lang prefixes list once in removeLanguageLinks()
Instead of just checking whether validLanguageLinks() is empty, it will build a list of language prefixes (including the obsolete ones) once and then reuses that list to remove all links which use one of the prefixes. This indirectly reduces the runtime as it'll won't call validLanguageLinks() twice if it's not empty.
Bug: T112256 Change-Id: Ie8462010561b510729e04a54447063957bd975f4 --- M pywikibot/textlib.py 1 file changed, 2 insertions(+), 2 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve XZise: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 7cefc3d..bda3503 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -793,12 +793,12 @@ """ if site is None: site = pywikibot.Site() - if not site.validLanguageLinks(): - return text # This regular expression will find every interwiki link, plus trailing # whitespace. languages = '|'.join(site.validLanguageLinks() + list(site.family.obsolete.keys())) + if not languages: + return text interwikiR = re.compile(r'[[(%s)\s?:[^[]\n]*]][\s]*' % languages, re.IGNORECASE) text = replaceExcept(text, interwikiR, '',
pywikibot-commits@lists.wikimedia.org