diff options
author | Minijackson | 2014-10-24 10:20:14 +0200 |
---|---|---|
committer | Minijackson | 2014-10-24 10:20:14 +0200 |
commit | a95864928cd74df172f172d7c18b4d89e82548e1 (patch) | |
tree | 7a2632e9f5172f36187995d1521228bb5e4e45d8 /banapedia | |
parent | a63aafe88b55c1c500646f5c93e9ff16780d37ca (diff) | |
download | wikistats-a95864928cd74df172f172d7c18b4d89e82548e1.tar.gz |
Moving to object type ban dict
Diffstat (limited to 'banapedia')
-rw-r--r-- | banapedia/Ban.py | 40 |
1 files changed, 0 insertions, 40 deletions
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: | |||
34 | 34 | ||
35 | self.country_code = country_code | 35 | self.country_code = country_code |
36 | return country_code | 36 | return country_code |
37 | |||
38 | |||
39 | def map_ban(ban_dict): | ||
40 | return Ban( | ||
41 | ban_dict["user"], | ||
42 | datetime.strptime(ban_dict["timestamp"], ISO_TIMESTAMP), | ||
43 | datetime.strptime(ban_dict["expiry"], ISO_TIMESTAMP), | ||
44 | ) | ||
45 | |||
46 | |||
47 | def map_bans(ban_dict_list): | ||
48 | ban_list = [] | ||
49 | for ban_dict in ban_dict_list: | ||
50 | ban_list.append(map_ban(ban_dict)) | ||
51 | |||
52 | return ban_list | ||
53 | |||
54 | |||
55 | def fetch_multipart_ban_dict(n, query_limit): | ||
56 | ban_dict_list = [] | ||
57 | n_fetched = 0 | ||
58 | continue_token = None | ||
59 | |||
60 | print("[INFO]", "Fetching %d bans" % n) | ||
61 | while n_fetched < n: | ||
62 | to_fetch = min(query_limit, n - n_fetched) | ||
63 | query = BlockQuery( | ||
64 | bkprop=["user", "timestamp", "expiry"], | ||
65 | bkshow=["temp", "ip"], | ||
66 | limit=to_fetch, | ||
67 | continue_token=continue_token, | ||
68 | ) | ||
69 | results = query.fetch_result() | ||
70 | ban_dict_list.extend(results["query"]["blocks"]) | ||
71 | continue_token = results["query-continue"]["blocks"]["bkcontinue"] | ||
72 | n_fetched += to_fetch | ||
73 | print("[INFO]", "Fetched %d over %d bans" % (n_fetched, n)) | ||
74 | |||
75 | print("[INFO]", "Bans fetching complete") | ||
76 | return ban_dict_list | ||