From a95864928cd74df172f172d7c18b4d89e82548e1 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 24 Oct 2014 10:20:14 +0200 Subject: Moving to object type ban dict --- banapedia/Ban.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'banapedia/Ban.py') diff --git a/banapedia/Ban.py b/banapedia/Ban.py index d8666b4..4714274 100644 --- a/banapedia/Ban.py +++ b/banapedia/Ban.py @@ -34,43 +34,3 @@ class Ban: self.country_code = country_code return country_code - - -def map_ban(ban_dict): - return Ban( - ban_dict["user"], - datetime.strptime(ban_dict["timestamp"], ISO_TIMESTAMP), - datetime.strptime(ban_dict["expiry"], ISO_TIMESTAMP), - ) - - -def map_bans(ban_dict_list): - ban_list = [] - for ban_dict in ban_dict_list: - ban_list.append(map_ban(ban_dict)) - - return ban_list - - -def fetch_multipart_ban_dict(n, query_limit): - ban_dict_list = [] - n_fetched = 0 - continue_token = None - - print("[INFO]", "Fetching %d bans" % n) - while n_fetched < n: - to_fetch = min(query_limit, n - n_fetched) - query = BlockQuery( - bkprop=["user", "timestamp", "expiry"], - bkshow=["temp", "ip"], - limit=to_fetch, - continue_token=continue_token, - ) - results = query.fetch_result() - ban_dict_list.extend(results["query"]["blocks"]) - continue_token = results["query-continue"]["blocks"]["bkcontinue"] - n_fetched += to_fetch - print("[INFO]", "Fetched %d over %d bans" % (n_fetched, n)) - - print("[INFO]", "Bans fetching complete") - return ban_dict_list -- cgit v1.2.3