Move get_geocoder function to config

This commit is contained in:
Cédric Leporcq 2021-07-31 20:11:39 +02:00
parent 0c8e454c7d
commit 00dbdb3a13
2 changed files with 8 additions and 12 deletions

View File

@ -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

View File

@ -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: