diff --git a/dozo/config.py b/dozo/config.py index 09057af..a88caea 100644 --- a/dozo/config.py +++ b/dozo/config.py @@ -36,3 +36,10 @@ def get_path_definition(config): return constants.default_path + '/' + constants.default_name +def get_geocoder(): + config = load_config(constants.CONFIG_FILE) + if 'Geolocation' in config and 'geocoder' in config['Geolocation']: + return config['Geolocation']['geocoder'] + + return constants.default_geocoder + diff --git a/dozo/geolocation.py b/dozo/geolocation.py index d60f3ac..bf146c6 100644 --- a/dozo/geolocation.py +++ b/dozo/geolocation.py @@ -12,7 +12,7 @@ import geopy from geopy.geocoders import Nominatim from dozo import constants -from dozo.config import load_config +from dozo.config import load_config, get_geocoder __KEY__ = None __DEFAULT_LOCATION__ = 'Unknown Location' @@ -107,17 +107,6 @@ def dms_string(decimal, type='latitude'): return '{} deg {}\' {}" {}'.format(dms[0], dms[1], dms[2], direction) -def get_geocoder(): - config = load_config(constants.CONFIG_FILE) - try: - geocoder = config['Geolocation']['geocoder'] - except KeyError as e: - log.error(e) - return None - - return geocoder - - def get_key(): global __KEY__ if __KEY__ is not None: