diff --git a/opencage/batch.py b/opencage/batch.py index 08bb040..b38f252 100644 --- a/opencage/batch.py +++ b/opencage/batch.py @@ -22,6 +22,7 @@ class OpenCageBatchGeocoder(): def __init__(self, options): self.options = options self.sslcontext = ssl.create_default_context(cafile=certifi.where()) + self.user_agent_comment = 'OpenCage CLI' self.write_counter = 1 def __call__(self, *args, **kwargs): @@ -74,7 +75,7 @@ async def geocode(self, csv_input, csv_output): async def test_request(self): try: - async with OpenCageGeocode(self.options.api_key, domain=self.options.api_domain, sslcontext=self.sslcontext, user_agent_comment='OpenCage CLI') as geocoder: + async with OpenCageGeocode(self.options.api_key, domain=self.options.api_domain, sslcontext=self.sslcontext, user_agent_comment=self.user_agent_comment) as geocoder: result = await geocoder.geocode_async('Kendall Sq, Cambridge, MA', raw_response=True) free = False @@ -170,7 +171,7 @@ def on_backoff(details): max_tries=self.options.retries, on_backoff=on_backoff) async def _geocode_one_address(): - async with OpenCageGeocode(self.options.api_key, domain=self.options.api_domain, sslcontext=self.sslcontext, user_agent_comment='OpenCage CLI') as geocoder: + async with OpenCageGeocode(self.options.api_key, domain=self.options.api_domain, sslcontext=self.sslcontext, user_agent_comment=self.user_agent_comment) as geocoder: geocoding_results = None params = { 'no_annotations': 1, **self.options.optional_api_params }