改为类

This commit is contained in:
Jing Ling
2020-08-19 02:13:35 +08:00
parent 0fb8f96272
commit 97f13b3851
2 changed files with 10 additions and 8 deletions
+9 -7
View File
@@ -1,11 +1,13 @@
import zipfile
import IP2Location
from IP2Location import IP2Location
from config.setting import data_storage_dir
zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN.ZIP")
bin_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN")
if not bin_path.exists():
zf = zipfile.ZipFile(zip_path)
zf.extract('IP2LOCATION-LITE-DB3.BIN', data_storage_dir)
IpGeoInfo = IP2Location.IP2Location(bin_path)
class IpGeoInfo(IP2Location):
def __init__(self):
zip_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN.ZIP")
bin_path = data_storage_dir.joinpath("IP2LOCATION-LITE-DB3.BIN")
if not bin_path.exists():
zf = zipfile.ZipFile(zip_path)
zf.extract('IP2LOCATION-LITE-DB3.BIN', data_storage_dir)
IP2Location.__init__(self, bin_path)