summaryrefslogtreecommitdiff
path: root/banapedia/Ban.py
diff options
context:
space:
mode:
Diffstat (limited to 'banapedia/Ban.py')
-rw-r--r--banapedia/Ban.py36
1 files changed, 0 insertions, 36 deletions
diff --git a/banapedia/Ban.py b/banapedia/Ban.py
deleted file mode 100644
index 4714274..0000000
--- a/banapedia/Ban.py
+++ /dev/null
@@ -1,36 +0,0 @@
1from banapedia.wapi.WikipediaQuery import BlockQuery
2from datetime import datetime
3import pygeoip
4
5__author__ = 'pacien'
6
7
8GEOIP_FILE = "/usr/share/GeoIP/GeoIP.dat"
9geoip = pygeoip.GeoIP(GEOIP_FILE)
10
11ISO_TIMESTAMP = "%Y-%m-%dT%H:%M:%SZ"
12
13
14class Ban:
15 def __init__(self, ip, start, end):
16 self.ip = ip
17 self.start = start
18 self.end = end
19 self.country_code = None
20
21 def get_duration(self):
22 return (self.end - self.start).days
23
24 def get_country_code(self):
25 if self.country_code is not None:
26 return self.country_code
27
28 country_code = ""
29
30 try:
31 country_code = geoip.country_code_by_addr(self.ip).lower()
32 except pygeoip.GeoIPError:
33 print("[ERROR]", "Could not determine country for ip", self.ip)
34
35 self.country_code = country_code
36 return country_code