Skip to content

Commit

Permalink
Move user_agent_comment for CLI to instance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
sbscully committed Nov 8, 2024
1 parent b652864 commit b32a626
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions opencage/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }

Expand Down

0 comments on commit b32a626

Please sign in to comment.