Move get_geocoder function to config
This commit is contained in:
parent
0c8e454c7d
commit
00dbdb3a13
|
@ -36,3 +36,10 @@ def get_path_definition(config):
|
||||||
|
|
||||||
return constants.default_path + '/' + constants.default_name
|
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
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import geopy
|
||||||
from geopy.geocoders import Nominatim
|
from geopy.geocoders import Nominatim
|
||||||
|
|
||||||
from dozo import constants
|
from dozo import constants
|
||||||
from dozo.config import load_config
|
from dozo.config import load_config, get_geocoder
|
||||||
|
|
||||||
__KEY__ = None
|
__KEY__ = None
|
||||||
__DEFAULT_LOCATION__ = 'Unknown Location'
|
__DEFAULT_LOCATION__ = 'Unknown Location'
|
||||||
|
@ -107,17 +107,6 @@ def dms_string(decimal, type='latitude'):
|
||||||
return '{} deg {}\' {}" {}'.format(dms[0], dms[1], dms[2], direction)
|
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():
|
def get_key():
|
||||||
global __KEY__
|
global __KEY__
|
||||||
if __KEY__ is not None:
|
if __KEY__ is not None:
|
||||||
|
|
Loading…
Reference in New Issue