Mercurial > lcfOS
view 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 source
#!/usr/bin/python2 from mercurial import ui, hg import numpy import matplotlib.pyplot as plt import datetime u = ui.ui() repo = hg.repository(u, '..') stamps = [] nds = repo.changelog.nodesbetween() for hexid in nds[0]: 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) 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()