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
|
from ..api.Query import JSONQuery
__author__ = 'pacien'
WIKIPEDIA_QUERY_BASE_URL = "https://en.wikipedia.org/w/api.php"
LIST_SEPARATOR = "|"
DEFAULT_BKPROP = ["id", "user", "userid", "by", "byid", "timestamp", "expiry", "reason", "range", "flags"]
DEFAULT_BKSHOW = ["account", "temp", "ip", "range"]
class WikipediaQuery(JSONQuery):
def __init__(self, params={}):
params.update({
"action": "query",
"format": "json",
})
JSONQuery.__init__(self, base_url=WIKIPEDIA_QUERY_BASE_URL, params=params)
class ListQuery(WikipediaQuery):
def __init__(self, list_name, params={}):
params.update({
"list": list_name,
})
WikipediaQuery.__init__(self, params)
class BlockQuery(ListQuery):
def __init__(self, bkprop=DEFAULT_BKPROP, bkshow=DEFAULT_BKSHOW, bkdir="newer", limit=500, continue_token=None):
params = {
"bkprop": LIST_SEPARATOR.join(bkprop),
"bkshow": LIST_SEPARATOR.join(bkshow),
"bkdir": bkdir,
"bklimit": limit,
}
if continue_token is not None:
params.update({"bkcontinue": continue_token})
ListQuery.__init__(self, "blocks", params=params)
|