From: Christian Heller Date: Thu, 11 Sep 2025 13:42:06 +0000 (+0200) Subject: Only declare respective level's direct children for log scopes. X-Git-Url: https://plomlompom.com/repos/reset_cookie?a=commitdiff_plain;h=c25fa3c5daaaf8af0dcebf6f7be3c5e3b61025d7;p=ircplom Only declare respective level's direct children for log scopes. --- diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index b69ec96..7a5a092 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -32,25 +32,25 @@ class _Update: 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): @@ -198,11 +198,11 @@ class _QueryWindow(_ChatWindow): 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, @@ -219,8 +219,7 @@ class _UpdatingChannel(_UpdatingNode): 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 = '' @@ -231,7 +230,7 @@ class _UpdatingUser(_UpdatingNode, NickUserHost): 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}' @@ -267,7 +266,7 @@ class _TuiClientDb(_UpdatingNode, SharedClientDbFields): motd: tuple[str, ...] = tuple() users: _UpdatingDict[_UpdatingUser] channels: _UpdatingDict[_UpdatingChannel] - log_scopes = {('connection_state',): LogScope.ALL} + log_scopes = {'connection_state': LogScope.ALL} class _ClientWindowsManager: