Skip to content

Commit 69c1007

Browse files
committed
version 1.5.0
1 parent 784579f commit 69c1007

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

example.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33

44
import pandas as pd
55

6+
def test_city_district():
7+
db = ipdb.City("c:/work/ipdb/test.ipdb")
8+
print(db.fields())
9+
city = db.find_info(u"111.199.81.160", "CN")
10+
qx = city.get_district()
11+
if qx != None:
12+
print(qx.city_name, qx.district_name)
613

714
def test_free():
815
db = ipdb.City("c:/work/ipdb/mydata4vipweek2.ipdb")
@@ -100,5 +107,5 @@ def test_idc_list():
100107
# test_city_ipv4()
101108
# test_city_ipv6_test()
102109
# test_base_station()
103-
test_city_ipv6()
110+
test_city_district()
104111
# test_city_ipv4()

ipdb/city.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"""
55

66
from .database import Reader
7-
7+
from .district import DistrictInfo
8+
import json
89

910
class CityInfo:
1011
country_name = ""
@@ -27,12 +28,23 @@ class CityInfo:
2728
currency_code = ""
2829
currency_name = ""
2930
anycast = ""
31+
line = ""
32+
district_info = ""
3033

3134
def __init__(self, **kwargs):
3235
self._map = kwargs
3336
for key in self._map:
3437
self.__dict__[key] = self._map[key]
3538

39+
def get_district(self):
40+
if len(self.district_info) == 0:
41+
return None
42+
o = json.loads(self.district_info)
43+
o["country_name"] = self.country_name
44+
o["region_name"] = self.region_name
45+
o["city_name"] = self.city_name
46+
return DistrictInfo(**o)
47+
3648

3749
class City:
3850

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='ipip-ipdb',
7-
version="1.3.2",
7+
version="1.5.0",
88
description=(
99
'IPIP.net officially supported IP database ipdb format parsing library'
1010
),

0 commit comments

Comments
 (0)