diff -r df2a6780cdf9 -r 74f6a0b01ddf log_formatter.py --- a/log_formatter.py Wed Feb 11 01:00:18 2009 +0200 +++ b/log_formatter.py Wed Feb 11 01:21:22 2009 +0200 @@ -35,13 +35,19 @@ self.img_ttf_path = img_ttf_path self.img_font_size = img_font_size - def _format_line_text (self, line, template_dict, full_timestamp=False) : + def _format_line_text (self, line, template_dict, type=None, full_timestamp=False) : """ - Format the given line as text, using the given { type: string template } dict + Format the given line as text, using the given { type: string template } dict. + + If type is given, then it overrides line.type """ + + # default type? + if type is None : + type = line.type # look up the template - template = template_dict[line.type] + template = template_dict[type] # convert timestamp into display timezone dtz = line.timestamp.astimezone(self.tz) @@ -173,6 +179,7 @@ LogTypes.QUIT : "%(timestamp)s -!- %(source_nickname)s [%(source_username)s@%(source_hostname)s] has quit [%(message)s]", LogTypes.TOPIC : "%(timestamp)s -!- %(source_nickname)s changed the topic of %(channel_name)s to: %(message)s", + 'TOPIC_UNSET' : "%(timestamp)s -!- Topic unset by %(source_nickname)s on %(channel_name)s", LogTypes.SELF_NOTICE: "%(timestamp)s -%(source_nickname)s- %(message)s", LogTypes.SELF_NICK : "%(timestamp)s -!- %(source_nickname)s is now known as %(target_nickname)s", @@ -181,8 +188,15 @@ def format_txt (self, lines, full_timestamps=False) : # ...handle each line for line in lines : + # specialcases + if line.type == LogTypes.TOPIC and line.data is None : + type = 'TOPIC_UNSET' + + else : + type = line.type + # using __TYPES - yield line, self._format_line_text(line, self.__FMT, full_timestamps) + yield line, self._format_line_text(line, self.__FMT, type, full_timestamps) class IrssiFormatter (BaseHTMLFormatter, IrssiTextFormatter) : """ @@ -206,7 +220,7 @@ # iterate for line in lines : # just dump - yield line, repr(line) + yield line, str(line) def by_name (name) : """