mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-06 17:32:31 -05:00
Split public and private config/driver APIs (#6024)
This commit is contained in:
@@ -35,7 +35,6 @@ log = logging.getLogger("red.config")
|
||||
_T = TypeVar("_T")
|
||||
|
||||
_config_cache = weakref.WeakValueDictionary()
|
||||
_retrieved = weakref.WeakSet()
|
||||
|
||||
|
||||
class ConfigMeta(type):
|
||||
@@ -65,14 +64,6 @@ class ConfigMeta(type):
|
||||
return instance
|
||||
|
||||
|
||||
def get_latest_confs() -> Tuple["Config"]:
|
||||
global _retrieved
|
||||
ret = set(_config_cache.values()) - set(_retrieved)
|
||||
_retrieved |= ret
|
||||
# noinspection PyTypeChecker
|
||||
return tuple(ret)
|
||||
|
||||
|
||||
class _ValueCtxManager(Awaitable[_T], AsyncContextManager[_T]): # pylint: disable=duplicate-bases
|
||||
"""Context manager implementation of config values.
|
||||
|
||||
@@ -1529,16 +1520,6 @@ class Config(metaclass=ConfigMeta):
|
||||
return self._lock_cache.setdefault(id_data, asyncio.Lock())
|
||||
|
||||
|
||||
async def migrate(cur_driver_cls: Type[BaseDriver], new_driver_cls: Type[BaseDriver]) -> None:
|
||||
"""Migrate from one driver type to another."""
|
||||
# Get custom group data
|
||||
core_conf = Config.get_core_conf(allow_old=True)
|
||||
core_conf.init_custom("CUSTOM_GROUPS", 2)
|
||||
all_custom_group_data = await core_conf.custom("CUSTOM_GROUPS").all()
|
||||
|
||||
await cur_driver_cls.migrate_to(new_driver_cls, all_custom_group_data)
|
||||
|
||||
|
||||
def _str_key_dict(value: Dict[Any, _T]) -> Dict[str, _T]:
|
||||
"""
|
||||
Recursively casts all keys in the given `dict` to `str`.
|
||||
|
||||
Reference in New Issue
Block a user