From: Christian Heller Date: Fri, 19 Sep 2025 15:05:35 +0000 (+0200) Subject: Minor code re-organization. X-Git-Url: https://plomlompom.com/repos/booking/do_day?a=commitdiff_plain;h=HEAD;p=ircplom Minor code re-organization. --- diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index 5e10d97..92a1429 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -342,19 +342,16 @@ class _ClientWindowsManager: self.db.recursive_set_and_report_change(update) if not update.results: return False - for t in update.results: - scope, value = t - log_path = ':'.join(update.full_path) + for scope, result in update.results: log_kwargs: dict[str, Any] = {'scope': scope} if scope in {LogScope.CHAT, LogScope.USER}: log_kwargs |= {'target': update.full_path[1]} - if value is None: - self.log(f'{log_path} cleared', **log_kwargs) - elif isinstance(value, Topic): - self.log(f'{value.who} set topic: {value.what}', **log_kwargs) - elif isinstance(value, list): + if isinstance(result, Topic): + self.log(f'{result.who} set topic: {result.what}', + **log_kwargs) + elif isinstance(result, list): msg = '' - for item in value: + for item in result: transform, content = item.split(':', maxsplit=1) if transform in {'NICK', 'NUH'}: nuh = self.db.users[content] @@ -362,13 +359,17 @@ class _ClientWindowsManager: msg += content self.log(msg, **log_kwargs) else: - announcement = f'{log_path} set to:' - if isinstance(value, tuple): - self.log(announcement, **log_kwargs) - for item in value: - self.log(f' {item}', **log_kwargs) + log_path = ':'.join(update.full_path) + if result is None: + self.log(f'{log_path} cleared', **log_kwargs) else: - self.log(f'{announcement} [{value}]', **log_kwargs) + announcement = f'{log_path} set to:' + if isinstance(result, tuple): + self.log(announcement, **log_kwargs) + for item in result: + self.log(f' {item}', **log_kwargs) + else: + self.log(f'{announcement} [{result}]', **log_kwargs) for win in [w for w in self.windows if isinstance(w, _ChatWindow)]: win.set_prompt_prefix() return bool([w for w in self.windows if w.tainted])