[V3 Config] Record custom group information using cog_add event (#2550)

* Do things differently

* Uncomment critical lines

* Reduce, reuse, recycle

* Check groups on all new config objects after a cog loads

* I don't know why this is failing now or why we need the global keyword

* gotta fix this too
This commit is contained in:
Will
2019-04-09 22:02:50 -04:00
committed by GitHub
parent e347ffa336
commit ba19179e4f
3 changed files with 25 additions and 0 deletions

View File

@@ -12,11 +12,22 @@ from .drivers import get_driver, IdentifierData
if TYPE_CHECKING:
from .drivers.red_base import BaseDriver
__all__ = ["Config", "get_latest_confs"]
log = logging.getLogger("red.config")
_T = TypeVar("_T")
_config_cache = weakref.WeakValueDictionary()
_retrieved = weakref.WeakSet()
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]):