-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_api_check.py
62 lines (48 loc) · 2 KB
/
demo_api_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import mwapi
import mwapi.cli
import mwreverts.api
session = mwapi.Session("https://en.wikipedia.org")
def format_revert(revert):
if revert is None:
return ""
else:
return " ".join([str(revert.reverting['revid']),
str([r['revid'] for r in revert.reverteds]),
str(revert.reverted_to['revid'])])
reverting, reverted, reverted_to = mwreverts.api.check(session, 679778587)
print("reverting:", format_revert(reverting))
print("reverted:", format_revert(reverted))
print("reverted_to:", format_revert(reverted_to))
print("---------------")
reverting, reverted, reverted_to = \
mwreverts.api.check(session, reverted.reverting['revid'])
print("reverting:", format_revert(reverting))
print("reverted:", format_revert(reverted))
print("reverted_to:", format_revert(reverted_to))
print("---------------")
reverting, reverted, reverted_to = \
mwreverts.api.check(session, reverting.reverted_to['revid'])
print("reverting:", format_revert(reverting))
print("reverted:", format_revert(reverted))
print("reverted_to:", format_revert(reverted_to))
print("---------------")
print("Let's to detect from deleted edits")
print("---------------")
mwapi.cli.do_login(session, "English Wikipedia")
reverting, reverted, reverted_to = \
mwreverts.api.check_deleted(session, 587400097)
print("reverting:", format_revert(reverting))
print("reverted:", format_revert(reverted))
print("reverted_to:", format_revert(reverted_to))
print("---------------")
reverting, reverted, reverted_to = \
mwreverts.api.check_deleted(session, reverted.reverting['revid'])
print("reverting:", format_revert(reverting))
print("reverted:", format_revert(reverted))
print("reverted_to:", format_revert(reverted_to))
print("---------------")
reverting, reverted, reverted_to = \
mwreverts.api.check_deleted(session, reverting.reverted_to['revid'])
print("reverting:", format_revert(reverting))
print("reverted:", format_revert(reverted))
print("reverted_to:", format_revert(reverted_to))