|
11 | 11 | from tqdm import tqdm |
12 | 12 | import certifi |
13 | 13 | import backoff |
14 | | -from opencage.geocoder import OpenCageGeocode, OpenCageGeocodeError, _query_for_reverse_geocoding, floatify_latlng |
| 14 | +from opencage.geocoder import ( |
| 15 | + OpenCageGeocode, |
| 16 | + OpenCageGeocodeError, |
| 17 | + _query_for_reverse_geocoding, |
| 18 | + floatify_latlng |
| 19 | +) |
15 | 20 |
|
16 | 21 |
|
17 | 22 | class OpenCageBatchGeocoder(): |
@@ -77,7 +82,12 @@ async def geocode(self, csv_input, csv_output): |
77 | 82 |
|
78 | 83 | async def test_request(self): |
79 | 84 | try: |
80 | | - async with OpenCageGeocode(self.options.api_key, domain=self.options.api_domain, sslcontext=self.sslcontext, user_agent_comment=self.user_agent_comment) as geocoder: |
| 85 | + async with OpenCageGeocode( |
| 86 | + self.options.api_key, |
| 87 | + domain=self.options.api_domain, |
| 88 | + sslcontext=self.sslcontext, |
| 89 | + user_agent_comment=self.user_agent_comment |
| 90 | + ) as geocoder: |
81 | 91 | result = await geocoder.geocode_async('Kendall Sq, Cambridge, MA', raw_response=True) |
82 | 92 |
|
83 | 93 | free = False |
@@ -175,7 +185,12 @@ def on_backoff(details): |
175 | 185 | max_tries=self.options.retries, |
176 | 186 | on_backoff=on_backoff) |
177 | 187 | async def _geocode_one_address(): |
178 | | - async with OpenCageGeocode(self.options.api_key, domain=self.options.api_domain, sslcontext=self.sslcontext, user_agent_comment=self.user_agent_comment) as geocoder: |
| 188 | + async with OpenCageGeocode( |
| 189 | + self.options.api_key, |
| 190 | + domain=self.options.api_domain, |
| 191 | + sslcontext=self.sslcontext, |
| 192 | + user_agent_comment=self.user_agent_comment |
| 193 | + ) as geocoder: |
179 | 194 | geocoding_results = None |
180 | 195 | response = None |
181 | 196 | params = {'no_annotations': 1, 'raw_response': True, **self.options.optional_api_params} |
@@ -208,7 +223,13 @@ async def _geocode_one_address(): |
208 | 223 | 'response': response |
209 | 224 | }) |
210 | 225 |
|
211 | | - await self.write_one_geocoding_result(csv_output, row_id, geocoding_result, response, original_columns) |
| 226 | + await self.write_one_geocoding_result( |
| 227 | + csv_output, |
| 228 | + row_id, |
| 229 | + geocoding_result, |
| 230 | + response, |
| 231 | + original_columns |
| 232 | + ) |
212 | 233 | except Exception as exc: |
213 | 234 | traceback.print_exception(exc, file=sys.stderr) |
214 | 235 |
|
|
0 commit comments