Mercurial > lcfOS
diff python/repostats.py2 @ 122:aaa4939a7942
Improved repostats
author | Windel Bouwman |
---|---|
date | Sat, 12 Jan 2013 12:49:27 +0100 |
parents | 347d7d8b96c0 |
children |
line wrap: on
line diff
--- a/python/repostats.py2 Sat Jan 12 12:35:02 2013 +0100 +++ b/python/repostats.py2 Sat Jan 12 12:49:27 2013 +0100 @@ -1,5 +1,9 @@ #!/usr/bin/python2 +import sys +# Use python 2 since mercurial does not support python 3 yet? +assert sys.version_info.major == 2 + from mercurial import ui, hg import numpy import matplotlib.pyplot as plt @@ -9,42 +13,25 @@ repo = hg.repository(u, '..') stamps = [] -nds = repo.changelog.nodesbetween() -for hexid in nds[0]: +nds = repo.changelog.nodesbetween()[0] +for hexid in nds: cset = repo.changelog.read(hexid) stamps.append(cset[2][0]) 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) +x = [dt.weekday() for dt in dts] +y = [dt.hour for dt in dts] -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) +# plot it: +f = plt.figure() +#plt.hexbin(x, y) +plt.scatter(x, y) +ax = plt.gca() +ax.set_ylim([0, 24]) +ax.set_ylabel('hour of day') +ax.set_xlim([0, 7]) +ax.set_xlabel('day of week') +ax.grid() plt.show()