Coalesce location into 3-tuple in geoip lookup

gregdan3/master
Gregory Danielson 4 years ago
parent 4996c5a553
commit ef477822ae
No known key found for this signature in database
GPG Key ID: 88D4EF22F6C14CA7

@ -165,14 +165,12 @@ def geoip(ip_addr):
try:
response = GEOIP_READER.city(ip_addr)
country = response.country.name
region = response.subdivisions.name
city = response.city.name
location = response.city.name, response.subdivisions.name, response.country.name
except geoip2.errors.AddressNotFoundError:
country = None
location = None, None, None
region = None
city = None
return city, region, country
return location
def workaround(city, region, country):
# workaround for the strange bug with the country name

Loading…
Cancel
Save