summaryrefslogtreecommitdiff
path: root/userparse.py
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-09-11 22:15:38 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-09-11 22:15:38 +0200
commitfcad165607ac7343ea86b5aae521b98de898760c (patch)
treed0e1777abbf851712d4fd1823330326ca72feed9 /userparse.py
parent41def8b92ca132560133149e4acbd9544b362be1 (diff)
Generate activity graphs for users.user_times
Diffstat (limited to 'userparse.py')
-rwxr-xr-xuserparse.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/userparse.py b/userparse.py
new file mode 100755
index 0000000..41d4d3d
--- /dev/null
+++ b/userparse.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python2
+
+import sys, datetime
+from pylab import *
+
+for fn in sys.argv[1:]:
+ f = open(fn, 'r')
+ channel = f.readline().strip().rsplit('/')[-1]
+ nick = f.readline().strip()
+
+ if channel.startswith('#'):
+ channel = channel[1:]
+
+ print('Graphing activity for {0} in #{1}'.format(nick, channel))
+
+ data = sorted(([int(y) for y in x.strip().split(',')] for x in f), key = lambda x: int(x[0]))
+ f.close()
+
+ fig = figure(figsize=(30, 6))
+ ax = fig.gca()
+ ax.xaxis.set_major_locator(MonthLocator(range(3, 13, 3)))
+ ax.xaxis.set_major_formatter(DateFormatter('%b %Y'))
+ grid(1)
+ xlabel('Time')
+ ylabel('Lines/day')
+ title('Activity for {0} in #{1}'.format(nick, channel))
+ bar([datetime.date.fromtimestamp(x[0]) for x in data], [sum(x[1:]) for x in data])
+
+ savefig('{0}-{1}.png'.format(channel, nick))