[pywikibot] Re: How to list logs?

2023-02-07 Thread JJMC89
I thought it may have been missing because it did not have a docstring, but
adding __doc__ did not add it to the docs. It functions the same as
LogEntry.

On Sun, Feb 5, 2023 at 11:33 PM Bináris  wrote:

> 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  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))
>> 
>>
>>
>> On Sun, Feb 5, 2023 at 3:31 PM Bináris  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 
>>> 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 
>>> 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 
>>> 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 
>>> 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 >> '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-le...@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-le...@lists.wikimedia.org
>>
>
>
> --
> Bináris
> ___
> pywikibot mailing list -- pywikibot@lists.wikimedia.org
> Public archives at
> https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/SIDFU4YBOOEENQ2KFJJYZKNEPXZMENBM/
> To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org
>
___
pywikibot mailing list -- pywikibot@lists.wikimedia.org
Public archives at 
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/SDJH5RNXHAQJ2C2OX7UHTP333QXVGBCI/
To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org


[pywikibot] Re: How to list logs?

2023-02-05 Thread Bináris
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  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))
> 
>
>
> On Sun, Feb 5, 2023 at 3:31 PM Bináris  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 
>> 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 
>> 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 
>> 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 
>> 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 > '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-le...@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-le...@lists.wikimedia.org
>


-- 
Bináris
___
pywikibot mailing list -- pywikibot@lists.wikimedia.org
Public archives at 
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/message/SIDFU4YBOOEENQ2KFJJYZKNEPXZMENBM/
To unsubscribe send an email to pywikibot-le...@lists.wikimedia.org


[pywikibot] Re: How to list logs?

2023-02-05 Thread JJMC89
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))



On Sun, Feb 5, 2023 at 3:31 PM Bináris  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 
> 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 
> 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 
> 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 
> 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  '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-le...@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-le...@lists.wikimedia.org