mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Docs] Add data manager information (#1056)
* Add Data Manager docs * Add rst file * Add note on data manager's purpose
This commit is contained in:
parent
923913f63d
commit
9394b4880e
11
docs/framework_datamanager.rst
Normal file
11
docs/framework_datamanager.rst
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.. data manager docs
|
||||||
|
|
||||||
|
============
|
||||||
|
Data Manager
|
||||||
|
============
|
||||||
|
|
||||||
|
Data manager is a module that handles all the information necessary to bootstrap
|
||||||
|
the bot into a state where more abstract data management systems can take over.
|
||||||
|
|
||||||
|
.. automodule:: redbot.core.data_manager
|
||||||
|
:members:
|
||||||
@ -31,8 +31,10 @@ Welcome to Red - Discord Bot's documentation!
|
|||||||
guide_cog_creation
|
guide_cog_creation
|
||||||
framework_bank
|
framework_bank
|
||||||
framework_cogmanager
|
framework_cogmanager
|
||||||
|
framework_datamanager
|
||||||
framework_config
|
framework_config
|
||||||
framework_downloader
|
framework_downloader
|
||||||
|
framework_i18n
|
||||||
framework_modlog
|
framework_modlog
|
||||||
framework_context
|
framework_context
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import appdirs
|
import appdirs
|
||||||
|
|
||||||
from .json_io import JsonIO
|
from .json_io import JsonIO
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from . import Config
|
||||||
|
|
||||||
__all__ = ['load_basic_configuration', 'cog_data_path', 'core_data_path',
|
__all__ = ['load_basic_configuration', 'cog_data_path', 'core_data_path',
|
||||||
'storage_details', 'storage_type']
|
'storage_details', 'storage_type']
|
||||||
|
|
||||||
@ -24,6 +28,19 @@ config_file = config_dir / 'config.json'
|
|||||||
|
|
||||||
|
|
||||||
def load_basic_configuration(instance_name_: str):
|
def load_basic_configuration(instance_name_: str):
|
||||||
|
"""Loads the basic bootstrap configuration necessary for `Config`
|
||||||
|
to know where to store or look for data.
|
||||||
|
|
||||||
|
.. important::
|
||||||
|
It is necessary to call this function BEFORE getting any `Config`
|
||||||
|
objects!
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
instance_name_ : str
|
||||||
|
The instance name given by CLI argument and created during
|
||||||
|
redbot setup.
|
||||||
|
"""
|
||||||
global jsonio
|
global jsonio
|
||||||
global basic_config
|
global basic_config
|
||||||
global instance_name
|
global instance_name
|
||||||
@ -50,12 +67,21 @@ def _base_data_path() -> Path:
|
|||||||
|
|
||||||
|
|
||||||
def cog_data_path(cog_instance=None) -> Path:
|
def cog_data_path(cog_instance=None) -> Path:
|
||||||
"""
|
"""Gets the base cog data path. If you want to get the folder with
|
||||||
Gets the base cog data path. If you want to get the folder with
|
|
||||||
which to store your own cog's data please pass in an instance
|
which to store your own cog's data please pass in an instance
|
||||||
of your cog class.
|
of your cog class.
|
||||||
:param cog_instance:
|
|
||||||
:return:
|
Parameters
|
||||||
|
----------
|
||||||
|
cog_instance
|
||||||
|
The instance of the cog you wish to get a data path for.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
pathlib.Path
|
||||||
|
If ``cog_instance`` is provided it will return a path to a folder
|
||||||
|
dedicated to a given cog. Otherwise it will return a path to the
|
||||||
|
folder that contains data for all cogs.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
base_data_path = Path(_base_data_path())
|
base_data_path = Path(_base_data_path())
|
||||||
@ -83,10 +109,11 @@ def core_data_path() -> Path:
|
|||||||
|
|
||||||
|
|
||||||
def storage_type() -> str:
|
def storage_type() -> str:
|
||||||
"""
|
"""Gets the storage type as a string.
|
||||||
Gets the storage type as a string.
|
|
||||||
|
|
||||||
:return:
|
Returns
|
||||||
|
-------
|
||||||
|
str
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return basic_config['STORAGE_TYPE']
|
return basic_config['STORAGE_TYPE']
|
||||||
@ -95,11 +122,13 @@ def storage_type() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def storage_details() -> dict:
|
def storage_details() -> dict:
|
||||||
"""
|
"""Gets any details necessary for config drivers to load.
|
||||||
Gets any details necessary for config drivers to load.
|
|
||||||
|
|
||||||
These are set on setup.
|
These are set on setup.
|
||||||
:return:
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
dict
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return basic_config['STORAGE_DETAILS']
|
return basic_config['STORAGE_DETAILS']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user