mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3 DataManager] Add some helper methods for interacting with bootstrapping configuration (#1029)
* Some helpers * Add dunder all
This commit is contained in:
parent
c80684a129
commit
5cfa7b6ed1
@ -5,6 +5,9 @@ import appdirs
|
|||||||
|
|
||||||
from .json_io import JsonIO
|
from .json_io import JsonIO
|
||||||
|
|
||||||
|
__all__ = ['load_basic_configuration', 'cog_data_path', 'core_data_path',
|
||||||
|
'storage_details', 'storage_type']
|
||||||
|
|
||||||
jsonio = None
|
jsonio = None
|
||||||
basic_config = None
|
basic_config = None
|
||||||
|
|
||||||
@ -72,3 +75,28 @@ def core_data_path() -> Path:
|
|||||||
core_path.mkdir(exist_ok=True, parents=True)
|
core_path.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
return core_path.resolve()
|
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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user