From ef477822aef61ab8e4ad036e6ad2592ef31517e1 Mon Sep 17 00:00:00 2001 From: Gregory Danielson Date: Sun, 1 Nov 2020 13:45:08 -0600 Subject: [PATCH] Coalesce location into 3-tuple in geoip lookup --- lib/location.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/location.py b/lib/location.py index 788da5e..7c66ca3 100644 --- a/lib/location.py +++ b/lib/location.py @@ -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