33 self.tz = tz |
33 self.tz = tz |
34 self.timestamp_fmt = timestamp_fmt |
34 self.timestamp_fmt = timestamp_fmt |
35 self.img_ttf_path = img_ttf_path |
35 self.img_ttf_path = img_ttf_path |
36 self.img_font_size = img_font_size |
36 self.img_font_size = img_font_size |
37 |
37 |
38 def _format_line_text (self, line, template_dict, full_timestamp=False) : |
38 def _format_line_text (self, line, template_dict, type=None, full_timestamp=False) : |
39 """ |
39 """ |
40 Format the given line as text, using the given { type: string template } dict |
40 Format the given line as text, using the given { type: string template } dict. |
41 """ |
41 |
|
42 If type is given, then it overrides line.type |
|
43 """ |
|
44 |
|
45 # default type? |
|
46 if type is None : |
|
47 type = line.type |
42 |
48 |
43 # look up the template |
49 # look up the template |
44 template = template_dict[line.type] |
50 template = template_dict[type] |
45 |
51 |
46 # convert timestamp into display timezone |
52 # convert timestamp into display timezone |
47 dtz = line.timestamp.astimezone(self.tz) |
53 dtz = line.timestamp.astimezone(self.tz) |
48 |
54 |
49 # full timestamps? |
55 # full timestamps? |
171 |
177 |
172 LogTypes.NICK : "%(timestamp)s -!- %(source_nickname)s is now known as %(target_nickname)s", |
178 LogTypes.NICK : "%(timestamp)s -!- %(source_nickname)s is now known as %(target_nickname)s", |
173 LogTypes.QUIT : "%(timestamp)s -!- %(source_nickname)s [%(source_username)s@%(source_hostname)s] has quit [%(message)s]", |
179 LogTypes.QUIT : "%(timestamp)s -!- %(source_nickname)s [%(source_username)s@%(source_hostname)s] has quit [%(message)s]", |
174 |
180 |
175 LogTypes.TOPIC : "%(timestamp)s -!- %(source_nickname)s changed the topic of %(channel_name)s to: %(message)s", |
181 LogTypes.TOPIC : "%(timestamp)s -!- %(source_nickname)s changed the topic of %(channel_name)s to: %(message)s", |
|
182 'TOPIC_UNSET' : "%(timestamp)s -!- Topic unset by %(source_nickname)s on %(channel_name)s", |
176 |
183 |
177 LogTypes.SELF_NOTICE: "%(timestamp)s -%(source_nickname)s- %(message)s", |
184 LogTypes.SELF_NOTICE: "%(timestamp)s -%(source_nickname)s- %(message)s", |
178 LogTypes.SELF_NICK : "%(timestamp)s -!- %(source_nickname)s is now known as %(target_nickname)s", |
185 LogTypes.SELF_NICK : "%(timestamp)s -!- %(source_nickname)s is now known as %(target_nickname)s", |
179 } |
186 } |
180 |
187 |
181 def format_txt (self, lines, full_timestamps=False) : |
188 def format_txt (self, lines, full_timestamps=False) : |
182 # ...handle each line |
189 # ...handle each line |
183 for line in lines : |
190 for line in lines : |
|
191 # specialcases |
|
192 if line.type == LogTypes.TOPIC and line.data is None : |
|
193 type = 'TOPIC_UNSET' |
|
194 |
|
195 else : |
|
196 type = line.type |
|
197 |
184 # using __TYPES |
198 # using __TYPES |
185 yield line, self._format_line_text(line, self.__FMT, full_timestamps) |
199 yield line, self._format_line_text(line, self.__FMT, type, full_timestamps) |
186 |
200 |
187 class IrssiFormatter (BaseHTMLFormatter, IrssiTextFormatter) : |
201 class IrssiFormatter (BaseHTMLFormatter, IrssiTextFormatter) : |
188 """ |
202 """ |
189 Implements plain black-and-white irssi-style formatting |
203 Implements plain black-and-white irssi-style formatting |
190 """ |
204 """ |