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)