2 Prints all reverted revisions of User:EpochFail.
4 from mw.api import Session
5 from mw.lib import reverts
7 # Gather a page's revisions from the API
8 api_session = Session("https://en.wikipedia.org/w/api.php")
9 revs = api_session.revisions.query(
10 titles={"User:EpochFail"},
11 properties={'ids', 'sha1'},
15 # Creates a revsion event iterator
16 rev_events = ((rev['sha1'], rev) for rev in revs)
18 # Detect and print reverts
19 for revert in reverts.detect(rev_events):
20 print("{0} reverted back to {1}".format(revert.reverting['revid'],
21 revert.reverted_to['revid']))