mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
beginning of a script to parse relay logs
This commit is contained in:
parent
1f9a4180e8
commit
33d6f212b2
1 changed files with 33 additions and 0 deletions
33
xwords4/scripts/log-parse.py
Executable file
33
xwords4/scripts/log-parse.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import sys, re
|
||||
|
||||
LINE = re.compile('(<0x.*>)(\d\d:\d\d:\d\d): (.*)$')
|
||||
DATE = re.compile('It\'s a new day: \d\d/\d\d/\d\d\d\d')
|
||||
nMatches = 0
|
||||
nDates = 0
|
||||
|
||||
def handleLine(thread, timestamp, rest):
|
||||
global nMatches
|
||||
nMatches += 1
|
||||
print "handleLine got", thread, "and", timestamp, "and", rest
|
||||
|
||||
def main():
|
||||
global nMatches, nDates
|
||||
|
||||
for line in sys.stdin:
|
||||
line.strip()
|
||||
mtch = LINE.match(line)
|
||||
if mtch:
|
||||
handleLine( mtch.group(1), mtch.group(2), mtch.group(3) )
|
||||
break
|
||||
mtch = DATE.match(line)
|
||||
if mtch:
|
||||
nDates += 1
|
||||
continue
|
||||
print "unmatched: ", line
|
||||
break
|
||||
|
||||
print "got", nMatches, "normal lines and", nDates, "dates."
|
||||
|
||||
main()
|
Loading…
Add table
Reference in a new issue