[Moin-user] Parser für simplen Chat
tw-public at gmx.de
Tue May 9 09:23:20 EDT 2006
> I had reduced the regex to:
> (?P<nick>.*?): # Nick
> \s+ # Space between the nick and
> (?P<msg>.*) # Message
> 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