jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/366206 )
Change subject: Handle non-items in ItemClaimFilterPageGenerator ......................................................................
Handle non-items in ItemClaimFilterPageGenerator
Now if there are non-items in the generator, we try to find the item first and then filter on it. However, we have to abandon preloading since we can no longer assert that we are working on a list of items.
I have also made the type check weaker, so that other types of entities are supported as well.
Bug: T137842 Bug: T160396 Bug: T170991 Change-Id: I06851f18d85228d5db77cdec5ed1e07fcda32f7a --- M pywikibot/pagegenerators.py 1 file changed, 5 insertions(+), 4 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index a38d7d2..bed56fd 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -511,7 +511,6 @@ dupfiltergen, self.subpage_max_depth)
if self.claimfilter_list: - dupfiltergen = PreloadingItemGenerator(dupfiltergen) for claim in self.claimfilter_list: dupfiltergen = ItemClaimFilterPageGenerator(dupfiltergen, claim[0], claim[1], @@ -1577,9 +1576,11 @@ @return: true if page contains the claim, false otherwise @rtype: bool """ - if not isinstance(page, pywikibot.ItemPage): - pywikibot.output(u'%s is not an ItemPage. Skipping.' % page) - return False + if not isinstance(page, pywikibot.WikibasePage): + try: + page = pywikibot.ItemPage.fromPage(page) + except pywikibot.NoPage: + return False for page_claim in page.get()['claims'].get(prop, []): if page_claim.target_equals(claim): if not qualifiers:
pywikibot-commits@lists.wikimedia.org