2015-08-25 11:54:11 +00:00
|
|
|
from importlib import import_module
|
2010-11-30 23:20:23 +00:00
|
|
|
|
2024-07-03 14:21:33 +00:00
|
|
|
from . import LazyConfig
|
|
|
|
|
from . import settings
|
2023-04-07 13:16:39 +00:00
|
|
|
|
|
|
|
|
config = LazyConfig()
|
2013-04-12 15:39:10 +00:00
|
|
|
|
2024-07-03 14:21:33 +00:00
|
|
|
|
2010-11-30 23:20:23 +00:00
|
|
|
def import_module_attr(path):
|
|
|
|
|
package, module = path.rsplit('.', 1)
|
|
|
|
|
return getattr(import_module(package), module)
|
2023-04-07 13:16:39 +00:00
|
|
|
|
2024-07-03 14:21:33 +00:00
|
|
|
|
2023-04-07 13:16:39 +00:00
|
|
|
def get_values():
|
|
|
|
|
"""
|
|
|
|
|
Get dictionary of values from the backend
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
# First load a mapping between config name and default value
|
2024-07-03 14:21:33 +00:00
|
|
|
default_initial = ((name, options[0]) for name, options in settings.CONFIG.items())
|
2023-04-07 13:16:39 +00:00
|
|
|
# Then update the mapping with actually values from the backend
|
2024-07-05 14:38:26 +00:00
|
|
|
return dict(default_initial, **dict(config._backend.mget(settings.CONFIG)))
|