class _UpdatingNode(AutoAttrMixin):
- log_scopes: dict[str, LogScope] = {'': LogScope.SERVER}
def _make_attr(self, cls: Callable, key: str):
return cls()
- @classmethod
- def _scope(cls, key: str) -> LogScope:
- scopes: dict[str, LogScope] = {}
- for c in cls.__mro__:
- if hasattr(c, 'log_scopes'):
- scopes = c.log_scopes | scopes
- return scopes.get(key, scopes[''])
-
def recursive_set_and_report_change(self, update: _Update) -> None:
'Apply update, and, if it makes a difference, add to its .results.'
update.force_log = update.force_log or (not self._is_set(update.key))
node.recursive_set_and_report_change(update)
else:
update.old_value = node
- scope = self._scope(update.key)
do_report = update.force_log
if update.value is None:
if self._is_set(update.key):
self._set(update.key, update.value)
do_report |= True
if do_report:
- update.results += [(scope,
+ update.results += [(LogScope.SERVER,
tuple(sorted(update.value))
if isinstance(update.value, set)
else update.value)]
class _UpdatingUser(_UpdatingNode, User):
- log_scopes = {'exit_msg': LogScope.USER_NO_CHANNELS}
prev_nick = '?'
def recursive_set_and_report_change(self, update: _Update) -> None:
msg = f':{self} quits'
if len(update.value) > 1:
msg += f': {update.value[1:]}'
- update.results += [(self._scope(update.key), [msg])]
+ update.results += [(LogScope.USER_NO_CHANNELS, [msg])]
@property
def prev(self) -> str: