jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Remove _imageinfo usage ......................................................................
[FIX] Remove _imageinfo usage
With d298facc _imageinfo has been replaced by _file_revisions. This is now remove all usage of it.
Change-Id: I01cadfc4f3c4bbd66f953c9527e85d0d0c2aa9a4 --- M pywikibot/data/api.py M pywikibot/page.py M pywikibot/site.py M tests/site_tests.py 4 files changed, 11 insertions(+), 17 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 70e512b..b57a61d 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -2374,10 +2374,7 @@
"""Like PageGenerator, but yields Category objects instead of Pages."""
- def result(self, pagedata): - """Convert page dict entry from api to Page object.""" - p = PageGenerator.result(self, pagedata) - return pywikibot.Category(p) + pass
@deprecated("PageGenerator") @@ -2385,13 +2382,7 @@
"""Like PageGenerator, but yields FilePage objects instead of Pages."""
- def result(self, pagedata): - """Convert page dict entry from api to Page object.""" - p = PageGenerator.result(self, pagedata) - filepage = pywikibot.FilePage(p) - if 'imageinfo' in pagedata: - filepage._imageinfo = pagedata['imageinfo'][0] - return filepage + pass
class PropertyGenerator(QueryGenerator): @@ -2583,9 +2574,7 @@
if 'imageinfo' in pagedict: assert(isinstance(page, pywikibot.FilePage)) - for file_rev in pagedict['imageinfo']: - file_revision = pywikibot.page.FileInfo(file_rev) - page._file_revisions[file_revision.timestamp] = file_revision + page._load_file_revisions(pagedict['imageinfo'])
if "categoryinfo" in pagedict: page._catinfo = pagedict["categoryinfo"] diff --git a/pywikibot/page.py b/pywikibot/page.py index 6da7532..0cdcbc8 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -2012,6 +2012,11 @@ if self.namespace() != 6: raise ValueError(u"'%s' is not in the file namespace!" % title)
+ def _load_file_revisions(self, imageinfo): + for file_rev in imageinfo: + file_revision = FileInfo(file_rev) + self._file_revisions[file_revision.timestamp] = file_revision + @property def latest_file_info(self): """Retrieve and store information of latest Image rev. of FilePage. diff --git a/pywikibot/site.py b/pywikibot/site.py index fe0c4ac..fc4cd5f 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4982,7 +4982,7 @@ # If we receive a nochange, that would mean we're in simulation # mode, don't attempt to access imageinfo if "nochange" not in result: - filepage._imageinfo = result["imageinfo"] + filepage._load_file_revisions(result["imageinfo"]) return
@deprecated_args(number="step", diff --git a/tests/site_tests.py b/tests/site_tests.py index 322f1ef..6b03fde 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -595,11 +595,11 @@ for impage in mysite.allimages(minsize=100, total=5): self.assertIsInstance(impage, pywikibot.FilePage) self.assertTrue(mysite.page_exists(impage)) - self.assertGreaterEqual(impage._imageinfo["size"], 100) + self.assertGreaterEqual(impage.latest_file_info["size"], 100) for impage in mysite.allimages(maxsize=2000, total=5): self.assertIsInstance(impage, pywikibot.FilePage) self.assertTrue(mysite.page_exists(impage)) - self.assertLessEqual(impage._imageinfo["size"], 2000) + self.assertLessEqual(impage.latest_file_info["size"], 2000)
def test_newfiles(self): """Test the site.newfiles() method."""
pywikibot-commits@lists.wikimedia.org