json
This commit is contained in:
parent
dd8e369ce5
commit
9112fed2f6
3 changed files with 5 additions and 4067 deletions
File diff suppressed because it is too large
Load diff
1
plugins/data/geoip_regions.json
Normal file
1
plugins/data/geoip_regions.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,21 +1,15 @@
|
|||
from util import hook
|
||||
import os.path
|
||||
import csv
|
||||
import pygeoip
|
||||
import json
|
||||
|
||||
# initalise geolocation database
|
||||
geo = pygeoip.GeoIP(os.path.abspath("./plugins/data/geoip.dat"))
|
||||
|
||||
|
||||
regions = {}
|
||||
# read region database
|
||||
with open("./plugins/data/geoip_regions.csv", "rb") as f:
|
||||
reader = csv.reader(f)
|
||||
for row in reader:
|
||||
country, region, region_name = row
|
||||
if not regions.has_key(country):
|
||||
regions[country] = {}
|
||||
regions[country][region] = region_name
|
||||
# load region database
|
||||
with open("./plugins/data/geoip_regions.json", "rb") as f:
|
||||
regions = json.loads(f.read())
|
||||
|
||||
|
||||
@hook.command
|
||||
|
|
Reference in a new issue