Page MenuHomePhabricator

Documentation of start, end, and reverse parameters in Site.logevents()
Open, Needs TriagePublic

Description

The current documentation for pywikibot.Site.logevents() is ambiguous about how the start, end, and reverse parameters work.

According to the MediaWiki API:Logevents documentation:

  • start : “The timestamp to start enumerating from.”
  • end : “The timestamp to stop enumerating at.”
  • reverse : “List oldest first. Note that the meaning of the 'start' and 'end' parameters is reversed when this is enabled.”

However, Pywikibot’s current docstring implies that start and end act like “after” and “before,” which can lead to confusion when users iterate through logs or check block events.

Solution
This task proposes updating the docstring to match the MediaWiki API wording exactly.

Proposed docstring update:

start : Timestamp, optional
    The timestamp to start enumerating from.
end : Timestamp, optional
    The timestamp to end enumerating at.
reverse : bool, optional
    If True, list oldest first and reverse the meaning of 'start' and 'end'.

Example code for testing parameters

import pywikibot
from datetime import datetime

site = pywikibot.Site('en', 'wikipedia')
start = datetime(2025, 9, 10, 12, 0, 0 )
end = datetime(2025, 9, 12, 12, 0, 0 )
reverse = True 

for entry in site.logevents(start=start, end=end, total=50, reverse=reverse):
    print(f"{entry.timestamp()}: {entry.type()} - {entry.action()}")

Documentation

Event Timeline

Nirmeetkamble added a subscriber: Zache.

@Zache Please let me know if any change required

Zache updated the task description. (Show Details)

@Xqt , @matej_suchanek , I was thinking to propose some PendingChangesBot (T405726) needed features to be implemented directly to Pywikibot (T57081). Namely doing FlaggedRevs review API support to Pywikibot. This documentation update ticket would for seeing if my documentation is good enough and also generally seeing how it goes. Would you check that this particular task is OK and comment on if the doing gerrit requests as part of Outreachy contribution period is ok? (we try not to flood anything with too many review requests)

Also beyond just having Pywikibot review API the secondary targets would be adding support for stabilizations and generators for unreviewed pages and pending changes. Another nice to have feature would be to able to read ORES and Liftwing model stats for revisions directly using pywikibot interface.

@Zache Please let me know if any change required

I made some visual updates and added some links + example for testing parameters. Lets wait and see what Xqt and Matej_suchanek answers

This is how GeneratorsMixin.loadrevisions documents starttime and endtime:

:keyword starttime: retrieve revisions starting at this Timestamp
:keyword endtime: stop upon reaching this Timestamp
:keyword rvdir: if false, retrieve newest revisions first (default);
    if true, retrieve oldest first

This is how MediaWiki API documents lestart and leend:

lestart
    The timestamp to start enumerating from. 
    Type: timestamp (allowed formats)

leend
    The timestamp to end enumerating. 
    Type: timestamp (allowed formats)

ledir
    In which direction to enumerate:

    newer
        List oldest first. Note: lestart has to be before leend.
    older
        List newest first (default). Note: lestart has to be later than leend.

    Jedna z následujících hodnot: newer, older
    Default: older

@matej_suchanek It would at least require mentioning that the meaning of start and end is switched depending on the reverse = True / False value, as you cannot know this based on the documentation and it needs to be learned by trial and error.

Change #1195742 had a related patch set uploaded (by Nirmeetkamble01; author: Nirmeetkamble01):

[pywikibot/core@master] [docs] Clarify start, end, and reverse parameters in Site.logevents()

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

Change #1195742 had a related patch set uploaded (by Nirmeetkamble01; author: Nirmeetkamble01):

[pywikibot/core@master] [docs] Clarify start, end, and reverse parameters in Site.logevents()

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

Change #1202123 had a related patch set uploaded (by Ezra yendau; author: Ezra yendau):

[pywikibot/core@master] fix logevents() start, end and reverse documentation

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

Change #1202123 had a related patch set uploaded (by Ezra yendau; author: Ezra yendau):

[pywikibot/core@master] fix pywikibot.site.logenvents() start, end and reverse documentation

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

Change #1202123 had a related patch set uploaded (by Ezra yendau; author: Ezra yendau):

[pywikibot/core@master] fix pywikibot.site.logenvents() start, end and reverse documentation

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