|
16 | 16 | from .exceptions import RequestQuotaExceededError, TimeoutExceededError |
17 | 17 | from .handler_utils import ( |
18 | 18 | API_URL, |
| 19 | + COUNTRY_EU_FILE_DEFAULT, |
19 | 20 | COUNTRY_FILE_DEFAULT, |
20 | 21 | BATCH_MAX_SIZE, |
21 | 22 | CACHE_MAXSIZE, |
@@ -43,11 +44,15 @@ def __init__(self, access_token=None, **kwargs): |
43 | 44 | # load countries file |
44 | 45 | self.countries = handler_utils.read_country_names( |
45 | 46 | kwargs.get("countries_file") |
| 47 | + if kwargs.get("countries_file") |
| 48 | + else COUNTRY_FILE_DEFAULT |
46 | 49 | ) |
47 | 50 |
|
48 | 51 | # load eu countries file |
49 | | - self.eu_countries = handler_utils.read_eu_country_names( |
| 52 | + self.eu_countries = handler_utils.read_country_names( |
50 | 53 | kwargs.get("eu_countries_file") |
| 54 | + if kwargs.get("eu_countries_file") |
| 55 | + else COUNTRY_EU_FILE_DEFAULT |
51 | 56 | ) |
52 | 57 |
|
53 | 58 | # setup req opts |
@@ -127,7 +132,9 @@ async def getDetails(self, ip_address=None, timeout=None): |
127 | 132 | details = await resp.json() |
128 | 133 |
|
129 | 134 | # format & cache |
130 | | - handler_utils.format_details(details, self.countries,self.eu_countries) |
| 135 | + handler_utils.format_details( |
| 136 | + details, self.countries, self.eu_countries |
| 137 | + ) |
131 | 138 | self.cache[cache_key(ip_address)] = details |
132 | 139 |
|
133 | 140 | return Details(details) |
@@ -277,7 +284,9 @@ async def _do_batch_req( |
277 | 284 | # format & fill up cache |
278 | 285 | for ip_address, details in json_resp.items(): |
279 | 286 | if isinstance(details, dict): |
280 | | - handler_utils.format_details(details, self.countries,self.eu_countries) |
| 287 | + handler_utils.format_details( |
| 288 | + details, self.countries, self.eu_countries |
| 289 | + ) |
281 | 290 | self.cache[cache_key(ip_address)] = details |
282 | 291 |
|
283 | 292 | # merge cached results with new lookup |
|
0 commit comments