[Moin-user] Parser für simplen Chat

Thomas Waldmann tw-public at gmx.de
Tue May 9 09:23:20 EDT 2006


> I  had reduced the regex to:
> 
> "(r"""
>            (?P<nick>.*?):        # Nick
>            \s+                            # Space between the nick and 
> message
>            (?P<msg>.*)                    # Message
>        """

Looks ok.

> I understand that the ouput gets formatted like this
> 
> 1.    self.out.write(formatter.table(1))
> (Make a table)
> 2.   self.out.write(formatter.table_row(1))
> (Make a row)
> 
> 3.               for g in ('time', 'nick', 'msg'):
> (3 "fields")

In your case, you have only 'nick' and 'msg' (see your regex).

> 4.        self.out.write(formatter.table_cell(1))
> (does  this mean open cell ( <td> ?))

Yes. And 0 closes it.

> 5. self.out.write(formatter.text(match.group(g) or ''))
> ( is this "pasting" content of 1 of the 3 values inside td ?

Yes, g (group) loop variable gets first 'time' then 'nick' then 'msg', 
so the original code fills 3 td with the match group of that name.

> A nice feature would be this behaviour:
> * every user gets a color (maybe one of 256 web colors?)

This is a bit more work. And maybe will look bad.




More information about the Moin-user mailing list