view MoinMoin/parser/ @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <>
date Thu, 22 Sep 2005 15:09:50 +0000
children 0c6ef399308f
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
    MoinMoin - IRC Log Parser (irssi style logs)

    @copyright: 2004 by Thomas Waldmann
    @license: GNU GPL, see COPYING for details.

import re
from MoinMoin import wikiutil

Dependencies = []

class Parser:
        Send IRC logs in a table
    extensions = ['.irc']
    Dependencies = []

    def __init__(self, raw, request, **kw):
        self.raw = raw
        self.request = request
        self.form = request.form
        self._ = request.getText
        self.out = kw.get('out', request)

    def format(self, formatter):
        lines = self.raw.split('\n')
        # TODO: Add support for displaying things like join and part messages.
        pattern = re.compile(r"""
            ((\[|\()?                      # Opening bracket for the timestamp (if it exists)
                (?P<time>([\d]?\d[:.]?)+)  # Timestamp as one or more :/.-separated groups of 1 or 2 digits (if it exists)
            (\]|\))?\s+)?                  # Closing bracket for the timestamp (if it exists) plus whitespace
             <\s*?(?P<nick>.*)\s*?>        # Nick
            \s+                            # Space between the nick and message
            (?P<msg>.*)                    # Message
        """, re.VERBOSE + re.UNICODE)
        for line in lines:
            match = pattern.match(line)
            if match:
                for g in ('time', 'nick', 'msg'):
                    self.out.write(formatter.text( or ''))