|
29 | 29 | import geoip2.models |
30 | 30 | import requests |
31 | 31 | from requests.utils import default_user_agent |
32 | | -from .errors import AddressNotFoundError, AuthenticationError, \ |
33 | | - GeoIP2Error, HTTPError, InvalidRequestError, OutOfQueriesError |
| 32 | +from .errors import (AddressNotFoundError, AuthenticationError, |
| 33 | + GeoIP2Error, HTTPError, InvalidRequestError, |
| 34 | + OutOfQueriesError) |
34 | 35 |
|
35 | 36 | import sys |
36 | 37 |
|
@@ -90,9 +91,9 @@ def __init__(self, user_id, license_key, host='geoip.maxmind.com', |
90 | 91 | locales=None): |
91 | 92 | if locales is None: |
92 | 93 | locales = ['en'] |
93 | | - self.locales = locales |
94 | | - self.user_id = user_id |
95 | | - self.license_key = license_key |
| 94 | + self._locales = locales |
| 95 | + self._user_id = user_id |
| 96 | + self._license_key = license_key |
96 | 97 | self._base_uri = 'https://%s/geoip/v2.0' % host |
97 | 98 |
|
98 | 99 | def city(self, ip_address='me'): |
@@ -149,12 +150,12 @@ def _response_for(self, path, model_class, ip_address): |
149 | 150 | if ip_address != 'me': |
150 | 151 | ip_address = str(ipaddress.ip_address(ip_address)) |
151 | 152 | uri = '/'.join([self._base_uri, path, ip_address]) |
152 | | - response = requests.get(uri, auth=(self.user_id, self.license_key), |
| 153 | + response = requests.get(uri, auth=(self._user_id, self._license_key), |
153 | 154 | headers={'Accept': 'application/json', |
154 | 155 | 'User-Agent': self._user_agent()}) |
155 | 156 | if response.status_code == 200: |
156 | 157 | body = self._handle_success(response, uri) |
157 | | - return model_class(body, locales=self.locales) |
| 158 | + return model_class(body, locales=self._locales) |
158 | 159 | else: |
159 | 160 | self._handle_error(response, uri) |
160 | 161 |
|
|
0 commit comments