class _UpdatingNode(AutoAttrMixin):
- log_scopes: dict[tuple[str, ...], LogScope] = {tuple(): LogScope.SERVER}
+ log_scopes: dict[str, LogScope] = {'': LogScope.SERVER}
def _make_attr(self, cls: Callable, key: str):
return cls()
@classmethod
- def _scope(cls, path: tuple[str, ...]) -> LogScope:
- scopes: dict[tuple[str, ...], LogScope] = {}
+ def _scope(cls, path: str) -> LogScope:
+ scopes: dict[str, LogScope] = {}
for c in cls.__mro__:
if hasattr(c, 'log_scopes'):
scopes = c.log_scopes | scopes
- return scopes.get(path, scopes[tuple()])
+ return scopes.get(path, scopes[''])
def set_and_check_for_change(self, update: _Update
) -> Optional[tuple[LogScope, Any]]:
'Apply update, return if that actually made a difference.'
key = update.path[0]
node = self._get(key)
- scope = self._scope(update.path)
+ scope = self._scope(key)
if len(update.path) == 1:
if update.value is None:
if not self._is_set(key):
class _UpdatingChannel(_UpdatingNode):
user_ids: tuple[str, ...] = tuple()
topic: Topic = Topic()
- log_scopes = {tuple(): LogScope.CHAT}
+ log_scopes = {'': LogScope.CHAT}
def set_and_check_for_change(self, update: _Update
) -> Optional[tuple[LogScope, Any]]:
- scope = self._scope(update.path)
+ scope = self._scope(update.path[0])
if update.path[-1] == 'topic':
if super().set_and_check_for_change(update):
return (scope,
class _UpdatingUser(_UpdatingNode, NickUserHost):
- log_scopes = {('nick',): LogScope.USER,
- ('exit_msg',): LogScope.USER}
+ log_scopes = {'nick': LogScope.USER, 'exit_msg': LogScope.USER}
prev_nick = '?'
modes = '?'
exit_msg = ''
if update.path[-1] == 'modes':
return super().set_and_check_for_change(update)
if super().set_and_check_for_change(update):
- scope = self._scope(update.path)
+ scope = self._scope(update.path[0])
msg = 'RAW: '
if update.path[-1] == 'nick':
return scope, msg + f'{self.prev} renames {update.value}'
motd: tuple[str, ...] = tuple()
users: _UpdatingDict[_UpdatingUser]
channels: _UpdatingDict[_UpdatingChannel]
- log_scopes = {('connection_state',): LogScope.ALL}
+ log_scopes = {'connection_state': LogScope.ALL}
class _ClientWindowsManager: