-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out get_latest_confs and migrate into redbot.core._config
- Loading branch information
Showing
5 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import weakref | ||
from typing import Tuple, Type | ||
|
||
from redbot.core.config import Config, _config_cache | ||
from redbot.core._drivers import BaseDriver | ||
|
||
__all__ = ("get_latest_confs", "migrate") | ||
|
||
_retrieved = weakref.WeakSet() | ||
|
||
|
||
def get_latest_confs() -> Tuple[Config, ...]: | ||
global _retrieved | ||
ret = set(_config_cache.values()) - set(_retrieved) | ||
_retrieved |= ret | ||
return tuple(ret) | ||
|
||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters