ws.interactive module

Collection of functions extending ws.client.api.API with various interactive tasks.


Check if the current api session is authenticated, otherwise ask for credentials.

Parameters:api – an ws.client.api.API instance
exception ws.interactive.InteractiveQuit

Bases: Exception

Raised when the user specified quit on the interactive prompt.

ws.interactive.edit_interactive(api, title, pageid, text_old, text_new, basetimestamp, summary, **kwargs)

A routine for interactive editing. Presents differences between the two revisions highlighted using ws.diff.diff_highlighted() and an interactive prompt to let the user decide what to do next:

  • y accepts the edit and calls API.edit.
  • n discards the edit.
  • q will raise InteractiveQuit exception to let the calling program know that it should quit.
  • e will open the revisions in an external merge program (configurable by the $DIFFPROG environment variable, defaults to vimdiff).
  • ? will print brief legend and repeat the highlighted diff and prompt.
  • api – a MediaWiki.api.API instance to operate on
  • text_old (str) – old page content
  • text_new (str) – new page content

Other parameters are the same as for ws.client.api.API.edit().