diff -r ca82d0fee336 -r 37e67ec434f3 log_parser.py --- a/log_parser.py Wed Feb 11 21:55:10 2009 +0200 +++ b/log_parser.py Wed Feb 11 22:01:53 2009 +0200 @@ -46,9 +46,11 @@ """ A parser for irssi logfiles """ + + # timestamp prefix, with trailing space + _TS = r'(?P[a-zA-Z0-9: ]+[a-zA-Z0-9])\s*' # subexpression parts - _TS = r'(?P\S+)' _NICK = r'(?P.+?)' _NICK2 = r'(?P.+?)' _TARGET = r'(?P.+?)' @@ -63,23 +65,23 @@ TYPE_EXPRS = ( ( LogTypes.LOG_OPEN, r'--- Log opened (?P.+)' ), ( LogTypes.LOG_CLOSE, r'--- Log closed (?P.+)' ), - ( LogTypes.MSG, _TS + r' <(?P.)' + _NICK + '> ' + _MSG ), - ( LogTypes.NOTICE, _TS + r' -' + _NICK + ':' + _CHAN + '- ' + _MSG ), - ( LogTypes.ACTION, _TS + r' \* ' + _NICK + ' ' + _MSG ), - ( LogTypes.JOIN, _TS + r' -!- ' + _NICK + ' \[' + _USERHOST + '\] has joined ' + _CHAN ), - ( LogTypes.PART, _TS + r' -!- ' + _NICK + ' \[' + _USERHOST + '\] has left ' + _CHAN + ' \[(?P.*?)\]' ), - ( LogTypes.KICK, _TS + r' -!- ' + _TARGET + ' was kicked from ' + _CHAN + ' by ' + _NICK + ' \[(?P.*?)\]' ), + ( LogTypes.MSG, _TS + r'<(?P.)' + _NICK + '> ' + _MSG ), + ( LogTypes.NOTICE, _TS + r'-' + _NICK + ':' + _CHAN + '- ' + _MSG ), + ( LogTypes.ACTION, _TS + r'\* ' + _NICK + ' ' + _MSG ), + ( LogTypes.JOIN, _TS + r'-!- ' + _NICK + ' \[' + _USERHOST + '\] has joined ' + _CHAN ), + ( LogTypes.PART, _TS + r'-!- ' + _NICK + ' \[' + _USERHOST + '\] has left ' + _CHAN + ' \[(?P.*?)\]' ), + ( LogTypes.KICK, _TS + r'-!- ' + _TARGET + ' was kicked from ' + _CHAN + ' by ' + _NICK + ' \[(?P.*?)\]' ), # XXX: use hostname instead of nickname for ServerMode - ( LogTypes.MODE, _TS + r' -!- (mode|ServerMode)/' + _CHAN + ' \[(?P.+?)\] by (?P\S+)' ), - ( LogTypes.NICK, _TS + r' -!- ' + _NICK + ' is now known as (?P\S+)' ), - ( LogTypes.QUIT, _TS + r' -!- ' + _NICK + ' \[' + _USERHOST + '\] has quit \[(?P.*?)\]' ), - ( LogTypes.TOPIC, _TS + r' -!- (' + _NICK + ' changed the topic of ' + _CHAN + ' to: (?P.*)|Topic unset by ' + _NICK2 + ' on ' + _CHAN2 + ')' ), + ( LogTypes.MODE, _TS + r'-!- (mode|ServerMode)/' + _CHAN + ' \[(?P.+?)\] by (?P\S+)' ), + ( LogTypes.NICK, _TS + r'-!- ' + _NICK + ' is now known as (?P\S+)' ), + ( LogTypes.QUIT, _TS + r'-!- ' + _NICK + ' \[' + _USERHOST + '\] has quit \[(?P.*?)\]' ), + ( LogTypes.TOPIC, _TS + r'-!- (' + _NICK + ' changed the topic of ' + _CHAN + ' to: (?P.*)|Topic unset by ' + _NICK2 + ' on ' + _CHAN2 + ')' ), - ( LogTypes.SELF_NOTICE, _TS + r' \[notice\(' + _CHAN + '\)\] ' + _MSG ), - ( LogTypes.SELF_NICK, _TS + r' -!- You\'re now known as (?P\S+)' ), + ( LogTypes.SELF_NOTICE, _TS + r'\[notice\(' + _CHAN + '\)\] ' + _MSG ), + ( LogTypes.SELF_NICK, _TS + r'-!- You\'re now known as (?P\S+)' ), - ( LogTypes.NETSPLIT_START, _TS + r' -!- Netsplit ' + _SRV1 + ' <-> ' + _SRV2 + ' quits: (?P[^(]+)( \(\+(?P\d+) more,\S+\))?'), - ( LogTypes.NETSPLIT_END, _TS + r' -!- Netsplit over, joins: (?P[^(]+)( \(\+(?P\d+) more\))?' ), + ( LogTypes.NETSPLIT_START, _TS + r'-!- Netsplit ' + _SRV1 + ' <-> ' + _SRV2 + ' quits: (?P[^(]+)( \(\+(?P\d+) more,\S+\))?'), + ( LogTypes.NETSPLIT_END, _TS + r'-!- Netsplit over, joins: (?P[^(]+)( \(\+(?P\d+) more\))?' ), ( 'DAY_CHANGED', r'--- Day changed (?P.+)' ), )