File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 33
44import 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
714def 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()
Original file line number Diff line number Diff line change 44"""
55
66from .database import Reader
7-
7+ from .district import DistrictInfo
8+ import json
89
910class 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
3749class City :
3850
Original file line number Diff line number Diff line change 44
55setup (
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 ),
You can’t perform that action at this time.
0 commit comments