]> code.communitydata.science - rises_declines_wikia_code.git/blob - mediawiki_dump_tools/Mediawiki-Utilities/examples/lib.reverts.api.py
add copy of the GPL
[rises_declines_wikia_code.git] / mediawiki_dump_tools / Mediawiki-Utilities / examples / lib.reverts.api.py
1 """
2 Prints the reverting rev_id, rev_id and reverted to rev_id of all reverted
3 revisions made by user "PermaNoob".
4 """
5 from mw.api import Session
6 from mw.lib import reverts
7
8 session = Session("https://en.wikipedia.org/w/api.php")
9 revisions = session.user_contribs.query(user={"PermaNoob"}, direction="newer")
10
11 for rev in revisions:
12     revert = reverts.api.check_rev(session, rev, window=60*60*24*2)
13     if revert is not None:
14         print("{0} reverted {1} to {2}".format(
15             revert.reverting['revid'],
16             rev['revid'],
17             revert.reverted_to['revid'])
18         )

Community Data Science Collective || Want to submit a patch?