Thank you! The reason is that I have not found any pattern how to do it, and tried to find something in docs.

However, https://doc.wikimedia.org/pywikibot/master/api_ref/logentries.html#module-logentries does not list DeleteEntry, and the search lists only results in tests, not the production modules. Is it a bug?

JJMC89 <jjmc89.wikimedia@gmail.com> ezt írta (időpont: 2023. febr. 6., H, 0:49):
Is there a reason that you're trying to use LogEntryListGenerator instead of the site's logevents method?

>>> import pywikibot
>>> site = pywikibot.Site()
>>> gen = site.logevents('delete')
>>> print(next(gen))
<DeleteEntry(wikipedia:test, logid=355908)>


On Sun, Feb 5, 2023 at 3:31 PM Bináris <wikiposta@gmail.com> wrote:
I tried to list delete log entries:

from pywikibot.data.api import LogEntryListGenerator
gen = LogEntryListGenerator('delete')
print(next(gen))

I get a wirning and an error:
WARNING: c:\Pywikibot\pywikibot\data\api\_generators.py:857: RuntimeWarning: LogEntryListGenerator invoked without a site
  super().__init__('logevents', **kwargs)

Traceback (most recent call last):
  File "pwb.py", line 39, in <module>
    sys.exit(main())
  File "pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "C:\Python37\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Python37\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "pywikibot\scripts\wrapper.py", line 516, in <module>
    main()
  File "pywikibot\scripts\wrapper.py", line 500, in main
    if not execute():
  File "pywikibot\scripts\wrapper.py", line 487, in execute
    run_python_file(filename, script_args, module)
  File "pywikibot\scripts\wrapper.py", line 148, in run_python_file
    main_mod.__dict__)
  File "scripts\userscripts\reasonstat.py", line 141, in <module>
    main()
  File "scripts\userscripts\reasonstat.py", line 112, in main
    print(next(gen))
  File "C:\Python37\lib\_collections_abc.py", line 317, in __next__
    return self.send(None)
  File "c:\Pywikibot\pywikibot\tools\collections.py", line 275, in send
    return next(self._started_gen)
  File "c:\Pywikibot\pywikibot\data\api\_generators.py", line 628, in generator
    yield from self._extract_results(resultdata)
  File "c:\Pywikibot\pywikibot\data\api\_generators.py", line 572, in _extract_results
    result = self.result(item)
  File "c:\Pywikibot\pywikibot\data\api\_generators.py", line 864, in result
    return self.entryFactory.create(pagedata)
  File "c:\Pywikibot\pywikibot\logentries.py", line 339, in create
    return self._creator(logdata)
  File "c:\Pywikibot\pywikibot\logentries.py", line 329, in <lambda>
    self._creator = lambda data: logclass(data, self._site)
  File "c:\Pywikibot\pywikibot\logentries.py", line 42, in __init__
    .format(expected_type, self.type()))
pywikibot.exceptions.Error: Wrong log type! Expecting delete, received review instead.
CRITICAL: Exiting due to uncaught exception <class 'pywikibot.exceptions.Error'>

What's wrong?

--
Bináris
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/4ALA4QMCAYGVI5Y6Z5JQGH3YL3PLDMSM/
To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
_______________________________________________
pywikibot mailing list -- pywikibot@lists.wikimedia.org
Public archives at https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/7I7NNIYG3C67FJGRTGDEZOKRH3P2RKRI/
To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org


--
Bináris