From 8430260527a8d99331b309a7b1402d1e94df9257 Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Thu, 23 Apr 2020 13:39:35 +0200 Subject: [PATCH] return location always --- tww/tww.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tww/tww.py b/tww/tww.py index 1bd690b..eb75505 100644 --- a/tww/tww.py +++ b/tww/tww.py @@ -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) - write_to_cache(query, location) - return location + 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):