jenkins-bot has submitted this change and it was merged.
Change subject: Make WikidataItemGenerator work if page is already on the repo ......................................................................
Make WikidataItemGenerator work if page is already on the repo
Bug: https://sourceforge.net/p/pywikipediabot/bugs/1653/ Change-Id: Ia9916450a077f6604a3bc3649da4715a280e5b52 --- M pywikibot/pagegenerators.py 1 file changed, 9 insertions(+), 1 deletion(-)
Approvals: Xqt: Looks good to me, but someone else must approve Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index 8318048..d07b9e0 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -816,13 +816,21 @@ # entry.title() returns a Page object yield entry.title()
+ def WikidataItemGenerator(gen): """ A wrapper generator used to take another generator and yield their relevant Wikidata items """ for page in gen: - yield pywikibot.ItemPage.fromPage(page) + if isinstance(page, pywikibot.ItemPage): + yield page + elif page.site.data_repository() == page.site: + # These are already items, just not item pages + # FIXME: If we've already fetched content, we should retain it + yield pywikibot.ItemPage(page.site, page.title()) + else: + yield pywikibot.ItemPage.fromPage(page)
#TODO below
pywikibot-commits@lists.wikimedia.org