diff python/repostats.py2 @ 121:347d7d8b96c0

Cleanup
author Windel Bouwman
date Sat, 12 Jan 2013 12:35:02 +0100
parents bb08633510bf
children aaa4939a7942
line wrap: on
line diff
--- a/python/repostats.py2	Sat Jan 12 10:56:12 2013 +0100
+++ b/python/repostats.py2	Sat Jan 12 12:35:02 2013 +0100
@@ -1,6 +1,8 @@
 #!/usr/bin/python2
 
 from mercurial import ui, hg
+import numpy
+import matplotlib.pyplot as plt
 import datetime
 
 u = ui.ui()
@@ -8,14 +10,41 @@
 
 stamps = []
 nds = repo.changelog.nodesbetween()
-print len(nds), nds
 for hexid in nds[0]:
    cset = repo.changelog.read(hexid)
-   print cset
-   ts = cset[2][0]
-   stamps.append(ts)
+   stamps.append(cset[2][0])
 
-print len(stamps)
 dts = [datetime.datetime.fromtimestamp(st) for st in stamps]
 print dts
 
+stats = numpy.zeros( (7, 24) )
+
+for dt in dts:
+   d = dt.weekday()
+   h = dt.hour
+   stats[d][h] += 1
+
+print stats
+def enclose(tag, content, options=''):
+   return '<{0} {2}>\n{1}\n</{0}>'.format(tag, content, options)
+def merge(*args):
+   print(args)
+   return '\n'.join(args)
+
+head = enclose('head', enclose('title', 'repo stats'))
+
+r1 = [enclose('td', td) for td in ['','Monday','Tuesday', 'Wed', 'Thur', 'Friday', 'S', 'S']]
+r1 = enclose('tr', merge(*r1))
+
+tc = merge(r1)
+
+table = enclose('table', tc, options='border="2"')
+body = enclose('body', enclose('h1', 'repo stats') + table)
+html = enclose('html', head + body)
+
+#with open('repostats.html', 'w') as f:
+#   f.write(html)
+
+plt.scatter(stats)
+plt.show()
+