improving get_config (#240)

selenium-screenshot-testing
Kevin Chung 2017-04-08 02:51:28 -04:00 committed by GitHub
parent 72f7eeb0a4
commit b2fc5a6fcd
1 changed files with 12 additions and 0 deletions

View File

@ -361,6 +361,18 @@ def delete_file(filename):
@cache.memoize()
def get_config(key):
with app.app_context():
value = app.config.get(key)
if value:
if value and value.isdigit():
return int(value)
elif value and isinstance(value, six.string_types):
if value.lower() == 'true':
return True
elif value.lower() == 'false':
return False
else:
return value
config = Config.query.filter_by(key=key).first()
if config and config.value:
value = config.value