mirror of
https://github.com/chubin/wttr.in.git
synced 2024-10-05 01:42:07 +02:00
fxed a regression (geolocation cache)
This commit is contained in:
parent
5e3ecaeaf4
commit
a62e3d979d
@ -105,7 +105,14 @@ def ipcache(ip_addr):
|
||||
|
||||
if os.path.exists(cached):
|
||||
location = open(cached, 'r').read().split(';')
|
||||
return location
|
||||
if len(location) > 3:
|
||||
return location[3], location[1]
|
||||
elif len(location) > 1:
|
||||
return location[0], location[1]
|
||||
else:
|
||||
return location[0], None
|
||||
|
||||
return None, None
|
||||
|
||||
def ip2location(ip_addr):
|
||||
"Convert IP address `ip_addr` to a location name"
|
||||
@ -125,12 +132,11 @@ def ip2location(ip_addr):
|
||||
pass
|
||||
|
||||
if location and ';' in location:
|
||||
ipcachewrite(ip_addr, location)
|
||||
location = location.split(';')[3], location.split(';')[1]
|
||||
else:
|
||||
location = location, None
|
||||
|
||||
if location:
|
||||
ipcachewrite(ip_addr, location)
|
||||
return location
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user