ws.diff module

ws.diff.diff_highlighted(old, new, fromfile='', tofile='', fromfiledate='', tofiledate='')

Returns a diff between two texts formatted with ANSI color sequences suitable for output in 256-color terminal.

When available, the WikEdDiff library and its AnsiFormatter is used. Otherwise the difflib module from the standard library is used to generate the diff in unified format and pygments is used (when available) as the highlighter.

Parameters
  • old – text to compare (old revision)

  • new – text to compare (new revision)

  • fromfile – original file name (used as meta data to format diff header)

  • tofile – new file name (used as meta data to format diff header)

  • fromfiledate – original file timestamp (used as meta data to format diff header)

  • tofiledate – new file timestamp (used as meta data to format diff header)

Returns

diff formatted with ANSI color sequences

ws.diff.diff_revisions(api, oldrevid, newrevid)

Get a visual diff of two revisions obtained via a MediaWiki API.

Calls diff_highlighted() and includes basic meta data (title, username, timestamp and comment) in the diff header.

Parameters
  • api – a MediaWiki.api.API instance to operate on

  • oldrevid – revision ID for old revision

  • newrevid – revision ID for new revision