logentries module#

Objects representing Mediawiki log entries.

class logentries.BlockEntry(apidata, site)[source]#

Bases: LogEntry

Block or unblock log entry.

It might contain a block or unblock depending on the action. The duration, expiry and flags are not available on unblock log entries.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

duration()[source]#

Return a datetime.timedelta representing the block duration.

Returns:

datetime.timedelta, or None if block is indefinite.

Return type:

Optional[timedelta]

expiry()[source]#

Return a Timestamp representing the block expiry date.

Return type:

Optional[Timestamp]

flags()[source]#

Return a list of (str) flags associated with the block entry.

It raises an Error if the entry is an unblocking log entry.

Returns:

list of flags strings

Return type:

List[str]

page()[source]#

Return the blocked account or IP.

Returns:

the Page object of username or IP if this block action targets a username or IP, or the blockid if this log reflects the removal of an autoblock

Return type:

Union[int, Page]

class logentries.LogEntry(apidata, site)[source]#

Bases: UserDict

Generic log entry.

LogEntry parameters may be retrieved by the corresponding method or the LogEntry key. The following statements are equivalent:

action = logentry.action() action = logentry[‘action’] action = logentry.data[‘action’]

Initialize object from a logevent dict returned by MW API.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

page()[source]#

Page on which action was performed.

Returns:

page on action was performed

Return type:

Union[int, Page]

timestamp()[source]#

Timestamp object corresponding to event timestamp.

Return type:

Timestamp

class logentries.LogEntryFactory(site, logtype=None)[source]#

Bases: object

LogEntry Factory.

Only available method is create()

Parameters:
  • site (pywikibot.site.BaseSite) – The site on which the log entries are created.

  • logtype (Optional[str]) – The log type of the log entries, if known in advance. If None, the Factory will fetch the log entry from the data to create each object.

create(logdata)[source]#

Instantiate the LogEntry object representing logdata.

Parameters:

logdata (Dict[str, Any]) – <item> returned by the api

Returns:

LogEntry object representing logdata

Return type:

LogEntry

classmethod get_entry_class(logtype)[source]#

Return the class corresponding to the @logtype string parameter.

Returns:

specified subclass of LogEntry

Parameters:

logtype (str) –

Return type:

LogEntry

Note

this class method cannot verify whether the given logtype already exits for a given site; to verify use Site.logtypes or use the get_valid_entry_class instance method instead.

get_valid_entry_class(logtype)[source]#

Return the class corresponding to the @logtype string parameter.

Returns:

specified subclass of LogEntry

Raises:

KeyError – logtype is not valid

Parameters:

logtype (str) –

Return type:

LogEntry

class logentries.MoveEntry(apidata, site)[source]#

Bases: LogEntry

Move log entry.

Initialize object from a logevent dict returned by MW API.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

suppressedredirect()[source]#

Return True if no redirect was created during the move.

Return type:

bool

property target_ns: Namespace#

Return namespace object of target page.

property target_page: Page#

Return target page object.

property target_title: str#

Return the target title.

class logentries.OtherLogEntry(apidata, site)[source]#

Bases: LogEntry

A log entry class for unspecified log events.

Initialize object from a logevent dict returned by MW API.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

class logentries.PatrolEntry(apidata, site)[source]#

Bases: LogEntry

Patrol log entry.

Initialize object from a logevent dict returned by MW API.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

property auto: bool#

Return auto patrolled.

property current_id: int#

Return the current id.

property previous_id: int#

Return the previous id.

class logentries.RightsEntry(apidata, site)[source]#

Bases: LogEntry

Rights log entry.

Initialize object from a logevent dict returned by MW API.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

property newgroups: List[str]#

Return new rights groups.

Changed in version 7.5: No longer raise KeyError if oldgroups does not exists or LogEntry has no additional data e.g. due to hidden data and insufficient rights.

property oldgroups: List[str]#

Return old rights groups.

Changed in version 7.5: No longer raise KeyError if oldgroups does not exists or LogEntry has no additional data e.g. due to hidden data and insufficient rights.

class logentries.UploadEntry(apidata, site)[source]#

Bases: LogEntry

Upload log entry.

Initialize object from a logevent dict returned by MW API.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

page()[source]#

Return FilePage on which action was performed.

Return type:

FilePage

class logentries.UserTargetLogEntry(apidata, site)[source]#

Bases: LogEntry

A log entry whose target is a user page.

Initialize object from a logevent dict returned by MW API.

Parameters:
  • apidata (Dict[str, Any]) –

  • site (pywikibot.site.BaseSite) –

page()[source]#

Return the target user.

This returns a User object instead of the Page object returned by the superclass method.

Returns:

target user

Return type:

User