mirror of
https://github.com/chubin/wttr.in
synced 2025-01-26 02:34:59 +00:00
Coalesce location into 3-tuple in geoip lookup
This commit is contained in:
parent
4996c5a553
commit
ef477822ae
1 changed files with 3 additions and 5 deletions
|
@ -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…
Reference in a new issue