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 itsAnsiFormatter
is used. Otherwise thedifflib
module from the standard library is used to generate the diff in unified format andpygments
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 onoldrevid – revision ID for old revision
newrevid – revision ID for new revision