mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 03:38:53 -05:00
parent
1b45397e67
commit
9feb7ad876
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import collections
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import Callable, Union, Tuple
|
from typing import Callable, Union, Tuple
|
||||||
|
|
||||||
@ -316,8 +317,24 @@ class Group(Value):
|
|||||||
All of this Group's attributes, resolved as raw data values.
|
All of this Group's attributes, resolved as raw data values.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
defaults = self.defaults
|
return self.nested_update(await self())
|
||||||
defaults.update(await self())
|
|
||||||
|
def nested_update(self, current, defaults=None):
|
||||||
|
"""Robust updater for nested dictionaries
|
||||||
|
|
||||||
|
If no defaults are passed, then the instance attribute 'defaults'
|
||||||
|
will be used.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if not defaults:
|
||||||
|
defaults = deepcopy(self.defaults)
|
||||||
|
|
||||||
|
for key, value in current.items():
|
||||||
|
if isinstance(value, collections.Mapping):
|
||||||
|
result = self.nested_update(value, defaults.get(key, {}))
|
||||||
|
defaults[key] = result
|
||||||
|
else:
|
||||||
|
defaults[key] = deepcopy(current[key])
|
||||||
return defaults
|
return defaults
|
||||||
|
|
||||||
async def set(self, value):
|
async def set(self, value):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user