from ..api.Query import JSONQuery WIKIPEDIA_QUERY_BASE_URL = "https://en.wikipedia.org/w/api.php" LIST_SEPARATOR = "|" class WikipediaQuery(JSONQuery): def __init__(self, params=None): if params is None: params = {} params.update({ "action": "query", "format": "json", }) super(WikipediaQuery, self).__init__(base_url=WIKIPEDIA_QUERY_BASE_URL, params=params) class ListQuery(WikipediaQuery): def __init__(self, list_name, params=None): if params is None: params = {} params.update({ "list": list_name, }) super(ListQuery, self).__init__(params) class BlockQuery(ListQuery): def __init__(self, properties=None, show=None, sort="newer", limit=500, continue_token=None): if properties is None: properties = [] if show is None: show = [] params = { "bkprop": LIST_SEPARATOR.join(properties), "bkshow": LIST_SEPARATOR.join(show), "bkdir": sort, "bklimit": limit, } if continue_token is not None: params.update({"bkcontinue": continue_token}) super(BlockQuery, self).__init__("blocks", params=params)