jenkins-bot has submitted this change and it was merged.
Change subject: Improvements of imagelinks regex ......................................................................
Improvements of imagelinks regex
regex match now:
<gallery position="center"> File:something.jpg| </gallery>
patch submitted by ce2014
Change-Id: Ifb66c2676016486deef56f574676e2e723cd62c1 --- M wikipedia.py 1 file changed, 5 insertions(+), 5 deletions(-)
Approvals: Xqt: Looks good to me, approved Alex S.H. Lin: Verified; Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/wikipedia.py b/wikipedia.py index 86d4f23..45880cc 100644 --- a/wikipedia.py +++ b/wikipedia.py @@ -3057,11 +3057,11 @@ results.append(ImagePage(page.site(), page.title())) # Find images in galleries pageText = self.get(get_redirect=followRedirects) - galleryR = re.compile('<gallery>.*?</gallery>', re.DOTALL) - galleryEntryR = re.compile('(?P<title>(%s|%s):.+?)(|.+)?\n' - % (self.site().image_namespace(), - self.site().family.image_namespace( - code='_default'))) + galleryR = re.compile('<gallery[^>]*>.*?</gallery>', re.DOTALL) + galleryEntryR = re.compile( + '(?P<title>(?:%s|%s):[|\r\n]+?)(?:|.*)?\r?\n' + % (self.site().image_namespace(), + self.site().family.image_namespace(code='_default'))) for gallery in galleryR.findall(pageText): for match in galleryEntryR.finditer(gallery): results.append(ImagePage(self.site(), match.group('title')))
pywikibot-commits@lists.wikimedia.org