jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/182639 )
Change subject: IMPROV] Page: Renamed isImage and isCategory ......................................................................
IMPROV] Page: Renamed isImage and isCategory
After ImagePage was renamed to FilePage, is Page.isImage() doing the same. As suggested in the comments there also already rename Page.isCategory.
Change-Id: I81e3c078296eab2447d22dffaa05598b7f5552a0 --- M pywikibot/page.py M scripts/casechecker.py M scripts/category.py M scripts/category_redirect.py M scripts/imagetransfer.py M scripts/interwiki.py M tests/page_tests.py 7 files changed, 35 insertions(+), 25 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified Xqt: Looks good to me, but someone else must approve
diff --git a/pywikibot/page.py b/pywikibot/page.py index 0299b5c..2f525b8 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -313,7 +313,7 @@ # use this form for sites like commons, where the # code is the same as the family name title = u'%s:%s' % (self.site.code, title) - elif textlink and (self.isImage() or self.isCategory()): + elif textlink and (self.is_filepage() or self.is_categorypage()): title = u':%s' % title elif self.namespace() == 0 and not section: withNamespace = True @@ -799,7 +799,7 @@
@rtype: bool """ - if not self.isCategory(): + if not self.is_categorypage(): return False if not hasattr(self, "_catredirect"): catredirs = self.site._category_redirects() @@ -882,13 +882,23 @@ "%s:%s" % (self.site.namespace(ns + 1), self.title(withNamespace=False)))
- def isCategory(self): + def is_categorypage(self): """Return True if the page is a Category, False otherwise.""" return self.namespace() == 14
- def isImage(self): - """Return True if this is an image description page, False otherwise.""" + @deprecated('is_categorypage') + def isCategory(self): + """DEPRECATED: use is_categorypage instead.""" + return self.is_categorypage() + + def is_filepage(self): + """Return True if this is an file description page, False otherwise.""" return self.namespace() == 6 + + @deprecated('is_filepage') + def isImage(self): + """DEPRECATED: use is_filepage instead.""" + return self.is_filepage()
@remove_last_args(('get_Index', )) def isDisambig(self): @@ -1068,7 +1078,7 @@ return set(['create']) if 'create' in p_types else set() else: p_types.remove('create') # no existing page allows that - if not self.isImage(): # only file pages allow upload + if not self.is_filepage(): # only file pages allow upload p_types.remove('upload') return p_types
diff --git a/scripts/casechecker.py b/scripts/casechecker.py index 80e206f..9faa1cb 100755 --- a/scripts/casechecker.py +++ b/scripts/casechecker.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- """Bot to find all pages on the wiki with mixed latin and cyrilic alphabets.""" # -# (C) Pywikibot team, 2006-2016 +# (C) Pywikibot team, 2006-2017 # # Distributed under the terms of the MIT license. # @@ -469,7 +469,7 @@ if i not in self.knownWords and self.romanNumSfxPtrn.match(i) is not None)
- if len(badWords) == 0 or self.Page(title).isImage(): + if len(badWords) == 0 or self.Page(title).is_filepage(): return count = 0 ambigBadWords = set() diff --git a/scripts/category.py b/scripts/category.py index fce3c7b..7e7bd69 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -110,7 +110,7 @@ # (C) Ben McIlwain (CydeWeys), 2006-2015 # (C) Anreas J Schwab, 2007 # (C) xqt, 2009-2016 -# (C) Pywikibot team, 2008-2016 +# (C) Pywikibot team, 2008-2017 # # Distributed under the terms of the MIT license. # @@ -814,8 +814,8 @@
listString = "" for article in setOfArticles: - if (not article.isImage() or - self.showImages) and not article.isCategory(): + if (not article.is_filepage() or + self.showImages) and not article.is_categorypage(): if self.talkPages and not article.isTalkPage(): listString += "*[[%s]] -- [[%s|talk]]\n" \ % (article.title(), diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py index 5f87ab7..8bb645a 100755 --- a/scripts/category_redirect.py +++ b/scripts/category_redirect.py @@ -23,7 +23,7 @@
""" # -# (C) Pywikibot team, 2008-2016 +# (C) Pywikibot team, 2008-2017 # # Distributed under the terms of the MIT license. # @@ -242,7 +242,7 @@ # race condition: someone else removed the redirect while we # were checking for it continue - if target.isCategory(): + if target.is_categorypage(): # this is a hard-redirect to a category page newtext = (u"{{%(template)s|%(cat)s}}" % {'cat': target.title(withNamespace=False), diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index 36f49a2..1d5c9d0 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -27,7 +27,7 @@ """ # # (C) Andre Engels, 2004 -# (C) Pywikibot team, 2004-2016 +# (C) Pywikibot team, 2004-2017 # # Distributed under the terms of the MIT license. # @@ -244,7 +244,7 @@ imagelist.extend( linkedPage.imagelinks( followRedirects=True)) - elif page.isImage(): + elif page.is_filepage(): imagePage = pywikibot.FilePage(page.site, page.title()) imagelist = [imagePage] else: diff --git a/scripts/interwiki.py b/scripts/interwiki.py index 513dd5b..0f45e60 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -2429,7 +2429,7 @@ # Check if the page contains at least 50 characters return len(page.text) < 50 else: - if not page.isCategory(): + if not page.is_categorypage(): txt = page.get() txt = textlib.removeLanguageLinks(txt, site=page.site) txt = textlib.removeCategoryLinks(txt, site=page.site) diff --git a/tests/page_tests.py b/tests/page_tests.py index fd7b63f..762bbfa 100644 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -398,24 +398,24 @@ self.assertEqual(p4.isTalkPage(), True)
def testIsCategory(self): - """Test isCategory method.""" + """Test is_categorypage method.""" site = self.get_site() p1 = pywikibot.Page(site, u"First page") p2 = pywikibot.Page(site, u"Category:Second page") p3 = pywikibot.Page(site, u"Category talk:Second page") - self.assertEqual(p1.isCategory(), False) - self.assertEqual(p2.isCategory(), True) - self.assertEqual(p3.isCategory(), False) + self.assertEqual(p1.is_categorypage(), False) + self.assertEqual(p2.is_categorypage(), True) + self.assertEqual(p3.is_categorypage(), False)
- def testIsImage(self): - """Test C{Page.isImage} check.""" + def testIsFile(self): + """Test C{Page.is_filepage} check.""" site = self.get_site() p1 = pywikibot.Page(site, u"First page") p2 = pywikibot.Page(site, u"File:Second page") p3 = pywikibot.Page(site, u"Image talk:Second page") - self.assertEqual(p1.isImage(), False) - self.assertEqual(p2.isImage(), True) - self.assertEqual(p3.isImage(), False) + self.assertEqual(p1.is_filepage(), False) + self.assertEqual(p2.is_filepage(), True) + self.assertEqual(p3.is_filepage(), False)
def testApiMethods(self): """Test various methods that rely on API."""
pywikibot-commits@lists.wikimedia.org