Page MenuHomePhabricator

Generators -onlyif / -onlyifnot should be able to filter pages (not only items)
Closed, ResolvedPublic

Description

I want to delete some categories from articles which are not about people. Ideally bot should check of wikidata item have P31=Q5

I:\pwb>pwb.py replace -onlyifnot:P31=Q5 -catr:Úmrtí_podle_dne_a_měsíce -regex "\[\[Kategorie:(Narození|Úmrtí) (.*?)\]\]\n" "" -summary:"Není biografie"
Traceback (most recent call last):
  File "I:\pwb\pwb.py", line 248, in <module>
    if not main():
  File "I:\pwb\pwb.py", line 242, in main
    run_python_file(filename, [filename] + args, argvu, file_package)
  File "I:\pwb\pwb.py", line 112, in run_python_file
    main_mod.__dict__)
  File ".\scripts\replace.py", line 1131, in <module>
    main()
  File ".\scripts\replace.py", line 1122, in main
    bot.run()
  File ".\scripts\replace.py", line 683, in run
    for page in self.generator:
  File "I:\pwb\pywikibot\pagegenerators.py", line 1864, in PreloadingGenerator
    for page in generator:
  File "I:\pwb\pywikibot\pagegenerators.py", line 1497, in filter
    for page in generator:
  File "I:\pwb\pywikibot\pagegenerators.py", line 1914, in PreloadingItemGenerator
    page = pywikibot.ItemPage(datasite, page.title())
  File "I:\pwb\pywikibot\page.py", line 3814, in __init__
    % self._link.title)
pywikibot.exceptions.InvalidTitle: 'Ahmed III.' is not a valid item page title
<class 'pywikibot.exceptions.InvalidTitle'>
CRITICAL: Closing network session.

Event Timeline

JAnD created this task.Jun 14 2016, 7:34 PM
Restricted Application added subscribers: pywikibot-bugs-list, Zppix, Aklapper. · View Herald TranscriptJun 14 2016, 7:34 PM
JAnD added a comment.Sep 26 2016, 5:38 AM

Another case

C:\pwb>pwb.py coordinate_import -onlyifnot:P31=Q13406463,P31=Q5 -start:Sez
ERROR: 'Sezam (kniha)' is not a valid item page title
Traceback (most recent call last):
  File "C:\pwb\pywikibot\bot.py", line 1919, in run
    for page in self.generator:
  File "C:\pwb\pywikibot\pagegenerators.py", line 1886, in PreloadingGenerator
    for page in generator:
  File "C:\pwb\pywikibot\pagegenerators.py", line 1519, in filter
    for page in generator:
  File "C:\pwb\pywikibot\pagegenerators.py", line 1936, in PreloadingItemGenerator
    page = pywikibot.ItemPage(datasite, page.title())
  File "C:\pwb\pywikibot\page.py", line 3842, in __init__
    % self._link.title)
InvalidTitle: 'Sezam (kniha)' is not a valid item page title
JAnD renamed this task from pagegenerator -onlyif should work with other pagegenerators to pagegenerator -onlyif / -onlyifnot gets "Foo is not a valid item page title".Sep 26 2016, 6:00 AM
JAnD added a project: Pywikibot-Wikidata.

Seems that -onlyif: and -onlyifnot: can only work as filters of items, not pages which are generated eg. using -start:.

matej_suchanek renamed this task from pagegenerator -onlyif / -onlyifnot gets "Foo is not a valid item page title" to Generators -onlyif / -onlyifnot should be able to filter pages (not only items).Oct 27 2016, 10:08 AM
Xqt triaged this task as Low priority.Jun 27 2017, 5:30 PM
Xqt added a project: Pywikibot.

Change 366206 had a related patch set uploaded (by Matěj Suchánek; owner: Matěj Suchánek):
[pywikibot/core@master] Handle non-items in ItemClaimFilterPageGenerator

https://gerrit.wikimedia.org/r/366206

Change 366206 merged by jenkins-bot:
[pywikibot/core@master] Handle non-items in ItemClaimFilterPageGenerator

https://gerrit.wikimedia.org/r/366206

matej_suchanek closed this task as Resolved.Sep 5 2017, 3:47 PM
matej_suchanek removed a project: Patch-For-Review.