File tree 3 files changed +22
-3
lines changed
3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 3
3
4
4
import pandas as pd
5
5
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 )
6
13
7
14
def test_free ():
8
15
db = ipdb .City ("c:/work/ipdb/mydata4vipweek2.ipdb" )
@@ -100,5 +107,5 @@ def test_idc_list():
100
107
# test_city_ipv4()
101
108
# test_city_ipv6_test()
102
109
# test_base_station()
103
- test_city_ipv6 ()
110
+ test_city_district ()
104
111
# test_city_ipv4()
Original file line number Diff line number Diff line change 4
4
"""
5
5
6
6
from .database import Reader
7
-
7
+ from .district import DistrictInfo
8
+ import json
8
9
9
10
class CityInfo :
10
11
country_name = ""
@@ -27,12 +28,23 @@ class CityInfo:
27
28
currency_code = ""
28
29
currency_name = ""
29
30
anycast = ""
31
+ line = ""
32
+ district_info = ""
30
33
31
34
def __init__ (self , ** kwargs ):
32
35
self ._map = kwargs
33
36
for key in self ._map :
34
37
self .__dict__ [key ] = self ._map [key ]
35
38
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
+
36
48
37
49
class City :
38
50
Original file line number Diff line number Diff line change 4
4
5
5
setup (
6
6
name = 'ipip-ipdb' ,
7
- version = "1.3.2 " ,
7
+ version = "1.5.0 " ,
8
8
description = (
9
9
'IPIP.net officially supported IP database ipdb format parsing library'
10
10
),
You can’t perform that action at this time.
0 commit comments