if len(update.rel_path) > 1:
update.decrement_path()
node.recursive_set_and_report_change(update)
- else:
- update.old_value = node
- do_report = update.force_log
- if update.value is None:
- if self._is_set(update.key):
- self._unset(update.key)
- do_report |= True
- elif update.old_value != update.value:
- self._set(update.key, update.value)
+ return
+ update.old_value = node
+ do_report = update.force_log
+ if update.value is None:
+ if self._is_set(update.key):
+ self._unset(update.key)
do_report |= True
- if do_report:
- update.results += [(_LogScope.DEBUG,
- tuple(sorted(update.value))
- if isinstance(update.value, set)
- else update.value)]
+ elif update.old_value != update.value:
+ self._set(update.key, update.value)
+ do_report |= True
+ if (not do_report) or update.full_path == ('message',):
+ return
+ result = (tuple(sorted(update.value)) if isinstance(update.value, set)
+ else update.value)
+ announcement = ':' + ':'.join(update.full_path) + ' '
+ if result is None:
+ announcement += 'cleared'
+ else:
+ announcement += 'set to:'
+ if not isinstance(result, tuple):
+ announcement += f' [{result}]'
+ scope = _LogScope.DEBUG
+ update.results += [(scope, [announcement])]
+ if isinstance(result, tuple):
+ update.results += [(scope, [f': {item}']) for item in result]
def _get(self, key: str) -> Any:
return getattr(self, key)
self.db.recursive_set_and_report_change(update)
if not update.results:
return False
-
for scope, result in update.results:
- log_kwargs: dict[str, Any] = {'scope': scope}
+ log_kwargs: dict[str, str | bool] = {}
if scope in {_LogScope.CHAT, _LogScope.USER,
_LogScope.USER_NO_CHANNELS}:
if update.full_path == ('message',):
log_kwargs['is_notice'] = update.value.is_notice
else:
log_kwargs['log_target'] = update.full_path[1]
-
- if isinstance(result, list):
- msg = ''
- for item in result:
- transform, content = item.split(':', maxsplit=1)
- if transform in {'NICK', 'NUH'}:
- nuh = self.db.users[content]
- content = str(nuh) if transform == 'NUH' else nuh.nick
- msg += content
- self.log(msg, **log_kwargs)
-
- elif not update.full_path == ('message',):
- log_path = ':'.join(update.full_path)
- if result is None:
- self.log(f'{log_path} cleared', **log_kwargs)
- else:
- 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)
-
+ msg = ''
+ for item in result:
+ transform, content = item.split(':', maxsplit=1)
+ if transform in {'NICK', 'NUH'}:
+ nuh = self.db.users[content]
+ content = str(nuh) if transform == 'NUH' else nuh.nick
+ msg += content
+ self.log(msg, scope=scope, **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])