From 5cfa7b6ed1b56c7b20ac084d6a6246149b85126f Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 17 Oct 2017 22:05:49 -0400 Subject: [PATCH] [V3 DataManager] Add some helper methods for interacting with bootstrapping configuration (#1029) * Some helpers * Add dunder all --- redbot/core/data_manager.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/redbot/core/data_manager.py b/redbot/core/data_manager.py index dd7447800..7bcb423da 100644 --- a/redbot/core/data_manager.py +++ b/redbot/core/data_manager.py @@ -5,6 +5,9 @@ import appdirs from .json_io import JsonIO +__all__ = ['load_basic_configuration', 'cog_data_path', 'core_data_path', + 'storage_details', 'storage_type'] + jsonio = None basic_config = None @@ -72,3 +75,28 @@ def core_data_path() -> Path: core_path.mkdir(exist_ok=True, parents=True) return core_path.resolve() + + +def storage_type() -> str: + """ + Gets the storage type as a string. + + :return: + """ + try: + return basic_config['STORAGE_TYPE'] + except KeyError as e: + raise RuntimeError('Bot basic config has not been loaded yet.') from e + + +def storage_details() -> dict: + """ + Gets any details necessary for config drivers to load. + + These are set on setup. + :return: + """ + try: + return basic_config['STORAGE_DETAILS'] + except KeyError as e: + raise RuntimeError('Bot basic config has not been loaded yet.') from e