countries --> country

This commit is contained in:
Juan Ignacio Sánchez Lara
2018-07-09 15:35:37 +02:00
parent b8475bac30
commit ae84122c3d
2 changed files with 8 additions and 7 deletions
@@ -106,7 +106,7 @@ class TomTomBulkGeocoder(TomTomGeocoder, StreetPointBulkGeocoder):
def _query(self, search): def _query(self, search):
(search_id, address, city, state, country) = search (search_id, address, city, state, country) = search
searchtext = ', '.join(filter(None, [address, city, state])) searchtext = ', '.join(filter(None, [address, city, state]))
return self._request_uri(searchtext=searchtext, countries=country) return self._request_uri(searchtext=searchtext, country=country)
def _parse_results(self, json_body): def _parse_results(self, json_body):
return [self._parse_response(item['statusCode'], item['response']) return [self._parse_response(item['statusCode'], item['response'])
@@ -30,13 +30,14 @@ class TomTomGeocoder(Traceable):
self._apikey = apikey self._apikey = apikey
self._logger = logger self._logger = logger
def _uri(self, searchtext, countries=None): def _uri(self, searchtext, country=None):
return API_BASEURI + self._request_uri(searchtext, countries, self._apikey) return HOST + API_BASEURI + \
self._request_uri(searchtext, country, self._apikey)
def _request_uri(self, searchtext, countries=None, apiKey=None): def _request_uri(self, searchtext, country=None, apiKey=None):
baseuri = REQUEST_BASEURI baseuri = REQUEST_BASEURI
if countries: if country:
baseuri += '&countrySet={}'.format(countries) baseuri += '&countrySet={}'.format(country)
baseuri = baseuri + '&key={apiKey}' if apiKey else baseuri baseuri = baseuri + '&key={apiKey}' if apiKey else baseuri
return URITemplate(baseuri).expand(apiKey=apiKey, return URITemplate(baseuri).expand(apiKey=apiKey,
searchtext=searchtext.encode('utf-8')) searchtext=searchtext.encode('utf-8'))
@@ -81,7 +82,7 @@ class TomTomGeocoder(Traceable):
if state_province: if state_province:
address.append(normalize(state_province)) address.append(normalize(state_province))
uri = HOST + self._uri(searchtext=', '.join(address), countries=country) uri = self._uri(searchtext=', '.join(address), country=country)
try: try:
response = requests.get(uri) response = requests.get(uri)