Skip to content

Commit

Permalink
Fix issue elpaso#32 variable 'url' referenced before assignement when…
Browse files Browse the repository at this point in the history
… using google API
  • Loading branch information
Florent Millet committed Aug 2, 2019
1 parent 820d61c commit a617f61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__pycache__/
*.py[cod]
*$py.class
*.pyc

# C extensions
*.so
Expand Down Expand Up @@ -97,3 +98,6 @@ ENV/

# mypy
.mypy_cache/

# pyCharm stuff
.idea/
12 changes: 6 additions & 6 deletions geocoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def __init__(self, api_key=None):
self.api_key = api_key

def geocode(self, address):
try:
url = self.url.format(**{'address': address.decode('utf8')})

if self.api_key is not None and self.api_key.replace(' ', '') != '':
url += self.url + '&key=' + self.api_key
else:
url = self.url
if self.api_key is not None and self.api_key.replace(' ', '') != '':
url += self.url + '&key=' + self.api_key
else:
url = self.url

try:
url = url.format(**{'address': address.decode('utf8')})
logMessage(url)
results = json.loads(NAM.request(url, blocking=True)[1].decode('utf8'))['results']
return [(rec['formatted_address'], (rec['geometry']['location']['lng'], rec['geometry']['location']['lat'])) for rec in results]
Expand Down

0 comments on commit a617f61

Please sign in to comment.