Skip to content

Commit 0c40920

Browse files
committed
Added support for district, ASN and AS.
1 parent c08ff10 commit 0c40920

File tree

7 files changed

+107
-50
lines changed

7 files changed

+107
-50
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
8.10.0 2023-04-19
2+
* Added support for district, ASN and AS.
3+
14
8.9.0 2022-10-14
25
* Added Country and Region class.
36

IP2Location/database.py

Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,30 @@
1111
MAX_IPV4_RANGE = 4294967295
1212
MAX_IPV6_RANGE = 340282366920938463463374607431768211455
1313

14-
_COUNTRY_POSITION = (0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
15-
_REGION_POSITION = (0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)
16-
_CITY_POSITION = (0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4)
17-
_LATITUDE_POSITION = (0, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)
18-
_LONGITUDE_POSITION = (0, 0, 0, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6)
19-
_ZIPCODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, 7, 0, 7, 7)
20-
_TIMEZONE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 7, 8, 8, 8, 7, 8, 0, 8, 8, 8, 0, 8, 8)
21-
_ISP_POSITION = (0, 0, 3, 0, 5, 0, 7, 5, 7, 0, 8, 0, 9, 0, 9, 0, 9, 0, 9, 7, 9, 0, 9, 7, 9, 9)
22-
_DOMAIN_POSITION = (0, 0, 0, 0, 0, 0, 0, 6, 8, 0, 9, 0, 10, 0, 10, 0, 10, 0, 10, 8, 10, 0, 10, 8, 10, 10)
23-
_NETSPEED_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 11,0, 11,8, 11, 0, 11, 0, 11, 0, 11, 11)
24-
_IDDCODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 12, 0, 12, 0, 12, 9, 12, 0, 12, 12)
25-
_AREACODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 ,13 ,0, 13, 0, 13, 10, 13, 0, 13, 13)
26-
_WEATHERSTATIONCODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 14, 0, 14, 0, 14, 0, 14, 14)
27-
_WEATHERSTATIONNAME_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 15, 0, 15, 0, 15, 0, 15, 15)
28-
_MCC_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 16, 0, 16, 9, 16, 16)
29-
_MNC_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 17, 0, 17, 10, 17, 17)
30-
_MOBILEBRAND_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 18, 0, 18, 11, 18, 18)
31-
_ELEVATION_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 19, 0, 19, 19)
32-
_USAGETYPE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 20, 20)
33-
_ADDRESSTYPE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21)
34-
_CATEGORY_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22)
14+
_COUNTRY_POSITION = (0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
15+
_REGION_POSITION = (0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)
16+
_CITY_POSITION = (0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4)
17+
_LATITUDE_POSITION = (0, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5)
18+
_LONGITUDE_POSITION = (0, 0, 0, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6)
19+
_ZIPCODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, 7, 0, 7, 7, 7)
20+
_TIMEZONE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 7, 8, 8, 8, 7, 8, 0, 8, 8, 8, 0, 8, 8, 8)
21+
_ISP_POSITION = (0, 0, 3, 0, 5, 0, 7, 5, 7, 0, 8, 0, 9, 0, 9, 0, 9, 0, 9, 7, 9, 0, 9, 7, 9, 9, 9)
22+
_DOMAIN_POSITION = (0, 0, 0, 0, 0, 0, 0, 6, 8, 0, 9, 0, 10, 0, 10, 0, 10, 0, 10, 8, 10, 0, 10, 8, 10, 10, 10)
23+
_NETSPEED_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 11,0, 11,8, 11, 0, 11, 0, 11, 0, 11, 11, 11)
24+
_IDDCODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 12, 0, 12, 0, 12, 9, 12, 0, 12, 12, 12)
25+
_AREACODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 ,13 ,0, 13, 0, 13, 10, 13, 0, 13, 13, 13)
26+
_WEATHERSTATIONCODE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 14, 0, 14, 0, 14, 0, 14, 14, 14)
27+
_WEATHERSTATIONNAME_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 15, 0, 15, 0, 15, 0, 15, 15, 15)
28+
_MCC_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 16, 0, 16, 9, 16, 16, 16)
29+
_MNC_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 17, 0, 17, 10, 17, 17, 17)
30+
_MOBILEBRAND_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 18, 0, 18, 11, 18, 18, 18)
31+
_ELEVATION_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 19, 0, 19, 19, 19)
32+
_USAGETYPE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 20, 20, 20)
33+
_ADDRESSTYPE_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21)
34+
_CATEGORY_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 22)
35+
_DISTRICT_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23)
36+
_ASN_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24)
37+
_AS_POSITION = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25)
3538

3639
if sys.version < '3':
3740
import urllib, httplib
@@ -150,6 +153,9 @@ class IP2LocationRecord:
150153
usage_type = "This parameter is unavailable in selected .BIN data file. Please upgrade data file."
151154
address_type = "This parameter is unavailable in selected .BIN data file. Please upgrade data file."
152155
category = "This parameter is unavailable in selected .BIN data file. Please upgrade data file."
156+
district = "This parameter is unavailable in selected .BIN data file. Please upgrade data file."
157+
asn = "This parameter is unavailable in selected .BIN data file. Please upgrade data file."
158+
as_name = "This parameter is unavailable in selected .BIN data file. Please upgrade data file."
153159

154160
def __str__(self):
155161
return str(self.__dict__)
@@ -317,6 +323,18 @@ def get_category(self, ip):
317323
''' Get category '''
318324
rec = self.get_all(ip)
319325
return rec and rec.category
326+
def get_district(self, ip):
327+
''' Get district '''
328+
rec = self.get_all(ip)
329+
return rec and rec.district
330+
def get_asn(self, ip):
331+
''' Get asn '''
332+
rec = self.get_all(ip)
333+
return rec and rec.asn
334+
def get_as(self, ip):
335+
''' Get as_name '''
336+
rec = self.get_all(ip)
337+
return rec and rec.as_name
320338

321339
def get_all(self, addr):
322340
''' Get the whole record with all fields read from the file
@@ -465,6 +483,15 @@ def calc_off(what, mid):
465483
if _CATEGORY_POSITION[self._dbtype] != 0:
466484
rec.category = self._reads(struct.unpack('<I', raw_positions_row[((_CATEGORY_POSITION[self._dbtype]-1) * 4 - 4) : ((_CATEGORY_POSITION[self._dbtype]-1) * 4)])[0] + 1)
467485

486+
if _DISTRICT_POSITION[self._dbtype] != 0:
487+
rec.district = self._reads(struct.unpack('<I', raw_positions_row[((_DISTRICT_POSITION[self._dbtype]-1) * 4 - 4) : ((_DISTRICT_POSITION[self._dbtype]-1) * 4)])[0] + 1)
488+
489+
if _ASN_POSITION[self._dbtype] != 0:
490+
rec.asn = self._reads(struct.unpack('<I', raw_positions_row[((_ASN_POSITION[self._dbtype]-1) * 4 - 4) : ((_ASN_POSITION[self._dbtype]-1) * 4)])[0] + 1)
491+
492+
if _AS_POSITION[self._dbtype] != 0:
493+
rec.as_name = self._reads(struct.unpack('<I', raw_positions_row[((_AS_POSITION[self._dbtype]-1) * 4 - 4) : ((_AS_POSITION[self._dbtype]-1) * 4)])[0] + 1)
494+
468495
return rec
469496

470497
def __iter__(self):
@@ -604,6 +631,9 @@ def _get_record(self, ip):
604631
rec.usage_type = "INVALID IP ADDRESS"
605632
rec.address_type = "INVALID IP ADDRESS"
606633
rec.category = "INVALID IP ADDRESS"
634+
rec.district = "INVALID IP ADDRESS"
635+
rec.asn = "INVALID IP ADDRESS"
636+
rec.as_name = "INVALID IP ADDRESS"
607637
return rec
608638
else:
609639
if ipv == 4:
@@ -647,6 +677,9 @@ def _get_record(self, ip):
647677
rec.usage_type = "IPV6 ADDRESS MISSING IN IPV4 BIN"
648678
rec.address_type = "IPV6 ADDRESS MISSING IN IPV4 BIN"
649679
rec.category = "IPV6 ADDRESS MISSING IN IPV4 BIN"
680+
rec.district = "IPV6 ADDRESS MISSING IN IPV4 BIN"
681+
rec.asn = "IPV6 ADDRESS MISSING IN IPV4 BIN"
682+
rec.as_name = "IPV6 ADDRESS MISSING IN IPV4 BIN"
650683
return rec
651684
# a, b = struct.unpack('!QQ', socket.inet_pton(socket.AF_INET6, ip))
652685
# ipno = (a << 64) | b

PKG-INFO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.0
22
Name: IP2Location
3-
Version: 8.9.0
3+
Version: 8.10.0
44
Summary: Python API for IP2Location database
55
Home-page: http://www.ip2location.com
66
Author: IP2Location

README.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# IP2Location 8.9.0
1+
# IP2Location 8.10.0
22

33

44
This is a IP2Location Python library that enables the user to find the country, region or state, city, latitude and longitude, ZIP code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type and IAB category by IP address or hostname originates from. The library reads the geo location information from **IP2Location BIN data** file.
@@ -38,29 +38,32 @@ Below is the description of the functions available in the **BIN Database** look
3838
| ----------------- | ------------------------------------------------------------ |
3939
| open | Open the IP2Location BIN data for lookup. Default mode: File I/O. |
4040
| close | Close and clean up the file pointer. |
41-
| get_all | Return the geolocation information in array. |
42-
| get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
43-
| get_country_long | Return the ISO3166-1 country name of the IP address. |
44-
| get_region | Return the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported |
45-
| get_city | Return the city name of the IP address. |
46-
| get_latitude | Return the city latitude of the IP address. |
47-
| get_longitude | Return the city longtitude of the IP address. |
48-
| get_isp | Return the ISP name of the IP address. |
49-
| get_domain | Return the domain name of IP address. |
50-
| get_zipcode | Return the zipcode of the city. |
51-
| get_timezone | Return the UTC time zone (with DST supported). |
52-
| get_netspeed | Return the Internet connection type. Please see [Internet Connection Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#internet-connection-type) for details. |
53-
| get_idd_code | Return the IDD prefix to call the city from another country. |
54-
| get_area_code | Return the area code of the city. |
55-
| get_weather_code | Return the nearest weather observation station code. |
56-
| get_weather_name | Return the nearest weather observation station name. |
57-
| get_mcc | Return the Mobile Country Codes (MCC). |
58-
| get_mnc | Return the Mobile Network Code (MNC). |
41+
| get_all | Returns the geolocation information in array. |
42+
| get_country_short | Returns the ISO3166-1 country code (2-digits) of the IP address. |
43+
| get_country_long | Returns the ISO3166-1 country name of the IP address. |
44+
| get_region | Returns the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported |
45+
| get_city | Returns the city name of the IP address. |
46+
| get_latitude | Returns the city latitude of the IP address. |
47+
| get_longitude | Returns the city longtitude of the IP address. |
48+
| get_isp | Returns the ISP name of the IP address. |
49+
| get_domain | Returns the domain name of IP address. |
50+
| get_zipcode | Returns the zipcode of the city. |
51+
| get_timezone | Returns the UTC time zone (with DST supported). |
52+
| get_netspeed | Returns the Internet connection type. Please see [Internet Connection Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#internet-connection-type) for details. |
53+
| get_idd_code | Returns the IDD prefix to call the city from another country. |
54+
| get_area_code | Returns the area code of the city. |
55+
| get_weather_code | Returns the nearest weather observation station code. |
56+
| get_weather_name | Returns the nearest weather observation station name. |
57+
| get_mcc | Returns the Mobile Country Codes (MCC). |
58+
| get_mnc | Returns the Mobile Network Code (MNC). |
5959
| get_mobile_brand | Commercial brand associated with the mobile carrier. Please visit [Mobile Carrier Coverage](https://www.ip2location.com/mobile-carrier-coverage) to view the coverage report. |
60-
| get_elevation | Return average height of city above sea level in meters (m). |
61-
| get_usage_type | Return the ISP's usage type of IP address. Please see [Usage Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#usage-type) for details. |
62-
| get_address_type | Return the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
63-
| get_category | Return the IAB content taxonomy category of IP address or domain name. You can get a full list of IAB content taxonomy category from [here](https://www.ip2location.com/free/iab-categories). |
60+
| get_elevation | Returns average height of city above sea level in meters (m). |
61+
| get_usage_type | Returns the ISP's usage type of IP address. Please see [Usage Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#usage-type) for details. |
62+
| get_address_type | Returns the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
63+
| get_category | Returns the IAB content taxonomy category of IP address or domain name. You can get a full list of IAB content taxonomy category from [here](https://www.ip2location.com/free/iab-categories). |
64+
| get_district | Returns the district or county name of IP address. |
65+
| get_asn | Returns the Autonomous system number (ASN) of IP address. |
66+
| get_as | Returns the Autonomous system (AS) name of IP address. |
6467

6568
## Web Service
6669

sample.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2005-2022 IP2Location.com
1+
# Copyright (C) 2005-2023 IP2Location.com
22
# All Rights Reserved
33
#
44
# This library is free software: you can redistribute it and/or
@@ -40,7 +40,10 @@
4040
print("Usage Type : " + rec.usage_type)
4141
print("Address Type : " + rec.address_type)
4242
print("Category : " + rec.category)
43-
print("\nYou may download the DB25 sample BIN at http://www.ip2location.com/downloads/sample6.bin.db25.zip for full data display.")
43+
print("District : " + rec.district)
44+
print("ASN : " + rec.asn)
45+
print("AS : " + rec.as_name)
46+
print("\nYou may download the DB26 sample BIN at http://www.ip2location.com/downloads/sample6.bin.db26.zip for full data display.")
4447

4548
# Web Service
4649
ws = IP2Location.IP2LocationWebService("demo","WS25",True)
@@ -69,5 +72,5 @@
6972
print(country.get_country_info("US"))
7073

7174
# Get region code by country code and region
72-
region = IP2Location1.Region(os.path.join("data", "IP2LOCATION-ISO3166-2.CSV")
75+
region = IP2Location.Region(os.path.join("data", "IP2LOCATION-ISO3166-2.CSV")
7376
print(region.get_region_code("US", "California"))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="IP2Location",
8-
version="8.9.0",
8+
version="8.10.0",
99
author="IP2Location",
1010
author_email="support@ip2location.com",
1111
description="This is an IP geolocation library that enables the user to find the country, region, city, latitude and longitude, ZIP code, time zone, ISP, domain name, area code, weather info, mobile info, elevation, usage type, address type and IAB category from an IP address. It supports both IPv4 and IPv6 lookup.",

tests/test_database.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def testinvaliddatabase():
1616

1717
def testfunctionexist():
1818
database = IP2Location.IP2Location(ipv4database)
19-
functions_list = ['open', 'close', 'get_all', 'get_country_short', 'get_country_long', 'get_region', 'get_city', 'get_latitude', 'get_longitude', 'get_isp', 'get_domain', 'get_zipcode', 'get_timezone', 'get_netspeed', 'get_idd_code', 'get_area_code', 'get_weather_code', 'get_weather_name', 'get_mcc', 'get_mnc', 'get_mobile_brand', 'get_elevation', 'get_usage_type']
19+
functions_list = ['open', 'close', 'get_all', 'get_country_short', 'get_country_long', 'get_region', 'get_city', 'get_latitude', 'get_longitude', 'get_isp', 'get_domain', 'get_zipcode', 'get_timezone', 'get_netspeed', 'get_idd_code', 'get_area_code', 'get_weather_code', 'get_weather_name', 'get_mcc', 'get_mnc', 'get_mobile_brand', 'get_elevation', 'get_usage_type', 'get_district', 'get_asn', 'get_as']
2020
for x in range(len(functions_list)):
2121
assert hasattr(database, functions_list[x]) == True, "Function did not exist."
2222

@@ -130,6 +130,21 @@ def testgetusagetype():
130130
rec = database.get_usage_type("8.8.8.8")
131131
assert rec == None
132132

133+
def testgetdistrict():
134+
database = IP2Location.IP2Location(ipv4database)
135+
rec = database.get_district("8.8.8.8")
136+
assert rec == None
137+
138+
def testgetasn():
139+
database = IP2Location.IP2Location(ipv4database)
140+
rec = database.get_asn("8.8.8.8")
141+
assert rec == None
142+
143+
def testgetas():
144+
database = IP2Location.IP2Location(ipv4database)
145+
rec = database.get_as("8.8.8.8")
146+
assert rec == None
147+
133148
def testipv6countrycode():
134149
database = IP2Location.IP2Location(ipv6database)
135150
rec = database.get_all("2001:4860:4860::8888")

0 commit comments

Comments
 (0)