Skip to content

Commit 517d537

Browse files
committed
Relax City/Country database checks
1 parent 8896248 commit 517d537

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

geoip2/database.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def country(self, ip_address):
5555
5656
"""
5757

58-
return self._model_for(geoip2.models.Country,
59-
['GeoIP2-Country', 'GeoLite2-Country'],
60-
ip_address)
58+
return self._model_for(geoip2.models.Country, 'Country', ip_address)
6159

6260
def city(self, ip_address):
6361
"""Get the City object for the IP address
@@ -67,9 +65,7 @@ def city(self, ip_address):
6765
:returns: :py:class:`geoip2.models.City` object
6866
6967
"""
70-
return self._model_for(geoip2.models.City,
71-
['GeoIP2-City', 'GeoLite2-City'],
72-
ip_address)
68+
return self._model_for(geoip2.models.City, 'City', ip_address)
7369

7470
def connection_type(self, ip_address):
7571
"""Get the ConnectionType object for the IP address
@@ -80,7 +76,7 @@ def connection_type(self, ip_address):
8076
8177
"""
8278
return self._flat_model_for(geoip2.models.ConnectionType,
83-
['GeoIP2-Connection-Type'],
79+
'GeoIP2-Connection-Type',
8480
ip_address)
8581

8682
def domain(self, ip_address):
@@ -92,7 +88,7 @@ def domain(self, ip_address):
9288
9389
"""
9490
return self._flat_model_for(geoip2.models.Domain,
95-
['GeoIP2-Domain'],
91+
'GeoIP2-Domain',
9692
ip_address)
9793

9894
def isp(self, ip_address):
@@ -104,11 +100,11 @@ def isp(self, ip_address):
104100
105101
"""
106102
return self._flat_model_for(geoip2.models.ISP,
107-
['GeoIP2-ISP'],
103+
'GeoIP2-ISP',
108104
ip_address)
109105

110-
def _get(self, types, ip_address):
111-
if not self.metadata().database_type in types:
106+
def _get(self, database_type, ip_address):
107+
if not database_type in self.metadata().database_type:
112108
caller = inspect.stack()[2][3]
113109
raise TypeError("The %s method cannot be used with the "
114110
"%s database" %

0 commit comments

Comments
 (0)