Move configuration defaults dict to module level
So that it is importable by tests
This commit is contained in:
parent
f7d5cbbd04
commit
cfc6b0d012
@ -65,22 +65,22 @@ def cardAnswer(card):
|
|||||||
return card.answer()
|
return card.answer()
|
||||||
|
|
||||||
|
|
||||||
def setting(key):
|
DEFAULT_CONFIG = {
|
||||||
defaults = {
|
'apiKey': None,
|
||||||
'apiKey': None,
|
'apiLogPath': None,
|
||||||
'apiLogPath': None,
|
'apiPollInterval': 25,
|
||||||
'apiPollInterval': 25,
|
'apiVersion': 6,
|
||||||
'apiVersion': 6,
|
'webBacklog': 5,
|
||||||
'webBacklog': 5,
|
'webBindAddress': os.getenv('ANKICONNECT_BIND_ADDRESS', '127.0.0.1'),
|
||||||
'webBindAddress': os.getenv('ANKICONNECT_BIND_ADDRESS', '127.0.0.1'),
|
'webBindPort': 8765,
|
||||||
'webBindPort': 8765,
|
'webCorsOrigin': os.getenv('ANKICONNECT_CORS_ORIGIN', None),
|
||||||
'webCorsOrigin': os.getenv('ANKICONNECT_CORS_ORIGIN', None),
|
'webCorsOriginList': ['http://localhost'],
|
||||||
'webCorsOriginList': ['http://localhost'],
|
'ignoreOriginList': [],
|
||||||
'ignoreOriginList': [],
|
'webTimeout': 10000,
|
||||||
'webTimeout': 10000,
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
def setting(key):
|
||||||
try:
|
try:
|
||||||
return aqt.mw.addonManager.getConfig(__name__).get(key, defaults[key])
|
return aqt.mw.addonManager.getConfig(__name__).get(key, DEFAULT_CONFIG[key])
|
||||||
except:
|
except:
|
||||||
raise Exception('setting {} not found'.format(key))
|
raise Exception('setting {} not found'.format(key))
|
||||||
|
Loading…
Reference in New Issue
Block a user