home · contact · privacy
Minor code re-organization. master
authorChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 15:05:35 +0000 (17:05 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 15:05:35 +0000 (17:05 +0200)
ircplom/client_tui.py

index 5e10d97746a153f9e179c406c3dd1b9fce5dbeb8..92a14299384cd596ff2f439139003c381a12ddb3 100644 (file)
@@ -342,19 +342,16 @@ class _ClientWindowsManager:
         self.db.recursive_set_and_report_change(update)
         if not update.results:
             return False
         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]}
             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 = ''
                 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]
                     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:
                     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:
                 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])
         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])