mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 01:12:33 -05:00
Add data_manager.instance_name() public API (#6146)
This commit is contained in:
@@ -18,16 +18,17 @@ __all__ = (
|
||||
"core_data_path",
|
||||
"bundled_data_path",
|
||||
"data_path",
|
||||
"instance_name",
|
||||
"metadata_file",
|
||||
"storage_details",
|
||||
"storage_type",
|
||||
"storage_details",
|
||||
)
|
||||
|
||||
log = logging.getLogger("red.data_manager")
|
||||
|
||||
basic_config = None
|
||||
|
||||
instance_name = None
|
||||
_instance_name = None
|
||||
|
||||
basic_config_default: Dict[str, Any] = {
|
||||
"DATA_PATH": None,
|
||||
@@ -106,8 +107,8 @@ def load_basic_configuration(instance_name_: str):
|
||||
redbot setup.
|
||||
"""
|
||||
global basic_config
|
||||
global instance_name
|
||||
instance_name = instance_name_
|
||||
global _instance_name
|
||||
_instance_name = instance_name_
|
||||
|
||||
try:
|
||||
with config_file.open(encoding="utf-8") as fs:
|
||||
@@ -119,7 +120,7 @@ def load_basic_configuration(instance_name_: str):
|
||||
)
|
||||
sys.exit(ExitCodes.CONFIGURATION_ERROR)
|
||||
try:
|
||||
basic_config = config[instance_name]
|
||||
basic_config = config[_instance_name]
|
||||
except KeyError:
|
||||
print(
|
||||
"Instance with this name doesn't exist."
|
||||
@@ -234,6 +235,17 @@ def data_path() -> Path:
|
||||
return _base_data_path()
|
||||
|
||||
|
||||
def instance_name() -> str:
|
||||
"""Gets instance's name.
|
||||
|
||||
Returns
|
||||
-------
|
||||
str
|
||||
Instance name.
|
||||
"""
|
||||
return _instance_name
|
||||
|
||||
|
||||
def metadata_file() -> Path:
|
||||
"""Gets the path of metadata file.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user