diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-08-15 13:50:18 +0200 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-08-15 13:50:18 +0200 |
commit | cccb1d97591966de1bab1b293294eefb17b90aac (patch) | |
tree | 25c379d4053297f7abd9aa40cefe8c6a7ccb6a5a | |
parent | b6e23355f1be8f02ab1e5284e65991382be76dbc (diff) | |
download | poezio-cccb1d97591966de1bab1b293294eefb17b90aac.tar.gz poezio-cccb1d97591966de1bab1b293294eefb17b90aac.tar.bz2 poezio-cccb1d97591966de1bab1b293294eefb17b90aac.tar.xz poezio-cccb1d97591966de1bab1b293294eefb17b90aac.zip |
logger: Simplify history loading, fixes mypy errors.
-rw-r--r-- | poezio/logger.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/poezio/logger.py b/poezio/logger.py index eb2809cc..7ac7ad7e 100644 --- a/poezio/logger.py +++ b/poezio/logger.py @@ -56,7 +56,7 @@ class LogMessage(LogItem): self.nick = nick -def parse_log_line(msg): +def parse_log_line(msg: str) -> Optional[LogItem]: match = re.match(MESSAGE_LOG_RE, msg) if match: return LogMessage(*match.groups()) @@ -328,23 +328,22 @@ def parse_log_lines(lines: List[str]) -> List[Dict[str, Any]]: if not isinstance(log_item, LogItem): log.debug('wrong log format? %s', log_item) continue + message_lines = [] message = { - 'lines': [], 'history': True, 'time': common.get_local_time(log_item.time) } size = log_item.nb_lines if isinstance(log_item, LogInfo): - message['lines'].append(color + log_item.text) + message_lines.append(color + log_item.text) elif isinstance(log_item, LogMessage): message['nickname'] = log_item.nick - message['lines'].append(color + log_item.text) + message_lines.append(color + log_item.text) while size != 0 and idx < len(lines): - message['lines'].append(lines[idx][1:]) + message_lines.append(lines[idx][1:]) size -= 1 idx += 1 - message['txt'] = '\n'.join(message['lines']) - del message['lines'] + message['txt'] = '\n'.join(message_lines) messages.append(message) return messages |