mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3 Config] Add MongoDB driver (#972)
* Basic Mongo Driver * Update docstrings * WIP motor support * Use motor * Update docs, add selective importer * Make use of selective importer * Fix docs * Fix config storage location for JSON * Add delimiters in the drivers doc section * Make async things async * Add basic config information for mongo driver * get info from basic setup into config * IT WORKS * Add dependency for RJM's PR.
This commit is contained in:
@@ -5,7 +5,7 @@ from typing import Callable, Union, Tuple
|
||||
import discord
|
||||
|
||||
from .data_manager import cog_data_path, core_data_path
|
||||
from .drivers.red_json import JSON as JSONDriver
|
||||
from .drivers import get_driver
|
||||
|
||||
log = logging.getLogger("red.config")
|
||||
|
||||
@@ -440,7 +440,18 @@ class Config:
|
||||
cog_name = cog_path_override.stem
|
||||
uuid = str(hash(identifier))
|
||||
|
||||
spawner = JSONDriver(cog_name, data_path_override=cog_path_override)
|
||||
# We have to import this here otherwise we have a circular dependency
|
||||
from .data_manager import basic_config
|
||||
|
||||
log.debug("Basic config: \n\n{}".format(basic_config))
|
||||
|
||||
driver_name = basic_config.get('STORAGE_TYPE', 'JSON')
|
||||
driver_details = basic_config.get('STORAGE_DETAILS', {})
|
||||
|
||||
log.debug("Using driver: '{}'".format(driver_name))
|
||||
|
||||
spawner = get_driver(driver_name, cog_name, data_path_override=cog_path_override,
|
||||
**driver_details)
|
||||
return cls(cog_name=cog_name, unique_identifier=uuid,
|
||||
force_registration=force_registration,
|
||||
driver_spawn=spawner)
|
||||
@@ -458,7 +469,16 @@ class Config:
|
||||
See `force_registration`.
|
||||
|
||||
"""
|
||||
driver_spawn = JSONDriver("Core", data_path_override=core_data_path())
|
||||
core_path = core_data_path()
|
||||
|
||||
# We have to import this here otherwise we have a circular dependency
|
||||
from .data_manager import basic_config
|
||||
|
||||
driver_name = basic_config.get('STORAGE_TYPE', 'JSON')
|
||||
driver_details = basic_config.get('STORAGE_DETAILS', {})
|
||||
|
||||
driver_spawn = get_driver(driver_name, "Core", data_path_override=core_path,
|
||||
**driver_details)
|
||||
return cls(cog_name="Core", driver_spawn=driver_spawn,
|
||||
unique_identifier='0',
|
||||
force_registration=force_registration)
|
||||
@@ -848,7 +868,7 @@ class Config:
|
||||
|
||||
"""
|
||||
if not scopes:
|
||||
group = Group(identifiers=(self.unique_identifier),
|
||||
group = Group(identifiers=(self.unique_identifier, ),
|
||||
defaults={},
|
||||
spawner=self.spawner)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user