return location always

This commit is contained in:
Daniel Tsvetkov 2020-04-23 13:39:35 +02:00
parent 85fcf2d6b5
commit 8430260527

View File

@ -38,12 +38,12 @@ DEFAULT_FORMAT = '%Y-%m-%d %H:%M:%S%z'
basepath = os.path.dirname(os.path.abspath(__file__))
class Location:
class Location(object):
"""
Represents a location with name, latitude and longitude
"""
def __init__(self, name: str, latitude: float, longitude: float):
def __init__(self, name: str = None, latitude: float = 0.0, longitude: float = 0.0):
self.name = name
self.latitude = latitude
self.longitude = longitude
@ -180,10 +180,12 @@ def resolve_location_remote(query):
geolocator = Nominatim(user_agent=user_agent)
try:
location = geolocator.geocode(query)
if location:
write_to_cache(query, location)
return location
except GeocoderTimedOut:
logger.info("Timed out resolving location. Try specifying a timezone directly")
return Location()
def parse_query(query):