jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Don't use deprecated methods in checkimages
......................................................................
[IMPROV] Don't use deprecated methods in checkimages
* use User class for talk page and title
* isRedirectPage() instead of try/except construct
* use list comprehension replacing templates
Bug: T95306
Change-Id: I26bfbdf403d93b504ac32e7924e3a5dd946ed4e0
---
M scripts/checkimages.py
1 file changed, 9 insertions(+), 20 deletions(-)
Approvals:
XZise: Looks good to me, but someone else must approve
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index a477953..f4613f5 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -754,15 +754,15 @@
repme)
return
upBots = i18n.translate(self.site, uploadBots)
- luser = pywikibot.url2link(nick, self.site, self.site)
+ user = pywikibot.User(self.site, nick)
+ luser = user.title(asUrl=True)
if upBots:
for upBot in upBots:
if upBot[0] == luser:
luser = self.uploadBotChangeFunction(reportPageText, upBot)
- talk_page = pywikibot.Page(self.site,
- u"%s:%s" % (self.site.namespace(3), luser))
- self.talk_page = talk_page
+ user = pywikibot.User(self.site, luser)
+ self.talk_page = user.getUserTalkPage()
self.luser = luser
return True
@@ -1290,15 +1290,11 @@
break
if not self.license_found:
for template in self.licenses_found:
- try:
- template.pageAPInfo()
- except pywikibot.IsRedirectPage:
+ if template.isRedirectPage():
template = template.getRedirectTarget()
result = self.miniTemplateCheck(template)
if result:
break
- except pywikibot.NoPage:
- continue
def smartDetection(self):
"""
@@ -1352,17 +1348,10 @@
self.templateInList()
if not self.license_found and self.allLicenses:
- # If only iterlist = self.AllLicenses if I remove something
- # from iterlist it will be remove from self.AllLicenses too
- iterlist = list(self.allLicenses)
-
- for template in iterlist:
- try:
- template.pageAPInfo()
- except pywikibot.IsRedirectPage:
- template = template.getRedirectTarget()
- except pywikibot.NoPage:
- self.allLicenses.remove(template)
+ self.allLicenses = [
+ template.getRedirectTarget()
+ if template.isRedirectPage() else template
+ for template in self.allLicenses if template.exists()]
if self.allLicenses:
self.license_found = self.allLicenses[0].title()
--
To view, visit
https://gerrit.wikimedia.org/r/203659
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I26bfbdf403d93b504ac32e7924e3a5dd946ed4e0
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>