equal
deleted
inserted
replaced
242 pytz.timezone -> tz_name |
242 pytz.timezone -> tz_name |
243 """ |
243 """ |
244 |
244 |
245 return tz.zone |
245 return tz.zone |
246 |
246 |
|
247 class ImageFont (Preference) : |
|
248 """ |
|
249 Font for ImageFormatter |
|
250 """ |
|
251 |
|
252 # set name |
|
253 name = 'image_font' |
|
254 |
|
255 def __init__ (self, font_dict, default_name) : |
|
256 """ |
|
257 Use the given { name: (path, title) } dict and default the given name |
|
258 """ |
|
259 |
|
260 self.font_dict = font_dict |
|
261 self.default = self.parse(default_name) |
|
262 |
|
263 def parse (self, name) : |
|
264 """ |
|
265 name -> (name, path, title) |
|
266 """ |
|
267 |
|
268 path, title = self.font_dict[name] |
|
269 |
|
270 return name, path, title |
|
271 |
|
272 def build (self, font_info) : |
|
273 """ |
|
274 (name, path, title) -> name |
|
275 """ |
|
276 |
|
277 name, path, title = font_info |
|
278 |
|
279 return name |
|
280 |
|
281 class ImageFontSize (urltree.URLIntegerType, Preference) : |
|
282 # set name, default |
|
283 name = 'image_font_size' |
|
284 default = config.PREF_IMAGE_FONT_SIZE_DEFAULT |
|
285 |
|
286 # XXX: params |
|
287 |
247 class Formatter (Preference) : |
288 class Formatter (Preference) : |
248 """ |
289 """ |
249 LogFormatter to use |
290 LogFormatter to use |
250 """ |
291 """ |
251 |
292 |
274 |
315 |
275 return fmt_cls.name |
316 return fmt_cls.name |
276 |
317 |
277 def process (self, prefs, fmt_cls) : |
318 def process (self, prefs, fmt_cls) : |
278 """ |
319 """ |
279 class LogFormatter -> LogFormatter(tz, time_fmt) |
320 class LogFormatter -> LogFormatter(tz, time_fmt, image_font.path) |
280 """ |
321 """ |
281 |
322 |
282 return fmt_cls(prefs[timezone], prefs[time_format]) |
323 font_name, font_path, font_title = prefs[image_font] |
|
324 font_size = prefs[image_font_size] |
|
325 |
|
326 return fmt_cls(prefs[timezone], prefs[time_format], font_path, font_size) |
283 |
327 |
284 class Count (urltree.URLIntegerType, Preference) : |
328 class Count (urltree.URLIntegerType, Preference) : |
285 """ |
329 """ |
286 Number of lines of log data to display per page |
330 Number of lines of log data to display per page |
287 """ |
331 """ |
297 |
341 |
298 # and then build the Preferences object |
342 # and then build the Preferences object |
299 time_format = TimeFormat() |
343 time_format = TimeFormat() |
300 date_format = DateFormat() |
344 date_format = DateFormat() |
301 timezone = Timezone() |
345 timezone = Timezone() |
|
346 image_font = ImageFont(config.FORMATTER_IMAGE_FONTS, config.PREF_IMAGE_FONT_DEFAULT) |
|
347 image_font_size = ImageFontSize() |
302 formatter = Formatter(config.LOG_FORMATTERS, config.PREF_FORMATTER_DEFAULT) |
348 formatter = Formatter(config.LOG_FORMATTERS, config.PREF_FORMATTER_DEFAULT) |
303 count = Count() |
349 count = Count() |
304 |
350 |
305 preferences = Preferences([ |
351 preferences = Preferences([ |
306 time_format, |
352 time_format, |
307 date_format, |
353 date_format, |
308 timezone, |
354 timezone, |
|
355 image_font, |
|
356 image_font_size, |
309 formatter, |
357 formatter, |
310 count, |
358 count, |
311 ]) |
359 ]) |
312 |
360 |