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:
--
To view, visit
https://gerrit.wikimedia.org/r/366206
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I06851f18d85228d5db77cdec5ed1e07fcda32f7a
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: JAn Dudík <jan.dudik(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>