forked from amstan/IRC-Analysis-Toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
populationGraph.py
executable file
·47 lines (33 loc) · 935 Bytes
/
populationGraph.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
from LogReader import *
from supybotParser import *
import re
import time
#import matplotlib.pyplot
enter = re.compile("(<.*>) (has joined #\w*)")
quit = re.compile("(<.*>) (has quit (IRC|irc)|has left #\w*)( \(.*\))?")
def populationGraph(filelist):
reader=LogReader(filelist)
log, _ = parseLog(reader)
population = 0
plot = ([],[])
for line in log:
if line[0]==MISC:
matches = (enter.match(line[3]),quit.match(line[3]))
if matches[0] is not None:
population += 1
#print "ENTER",
elif matches[1] is not None:
population -= 1
#print "QUIT",
else:
print line
continue
timestamp=time.strptime(line[1],"%Y-%m-%dT%H:%M:%S")
#print "%s population: %s, reason: %s" % (line[1],population,line[3])
plot[0].append(timestamp)
plot[1].append(population)
print plot[1]
if __name__ == "__main__":
import sys
populationGraph(sys.argv[1:])