Files
gitdm/csv.py
Michael Meeks d1a8929872 gitdm patch ...
Hi guys,

	I knocked up a patch to generate some per-month, by-affiliation
statistics from the gitdm output; attached for interest or merging.

	A sample of the output, complete with OO.o data-pilot, and pretty chart
is here:

http://www.gnome.org/~michael/data/2008-09-29-linux-stats.ods

	with chart here:
	http://www.gnome.org/~michael/images/2008-09-29-kernel-active.png

	caption being:

	"Graph showing number and affiliation of active kernel developers
(contributing more than 100 lines per month). Quick affiliation key,
from bottom up: Unknown, No-Affiliation, IBM, RedHat, Novell, Intel ..."

	These are as yet not published, I plan to use them as a comparison to
OO.o's somewhat mediocre equivalents; hope to go live with them soon
(and fix the horrible bugs in stacked area charts to make them actually
pretty ).

	HTH,

		Michael.

--
 michael.meeks@novell.com  <><, Pseudo Engineer, itinerant idiot

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2008-10-06 14:29:27 -06:00

39 lines
1.3 KiB
Python

#
# aggregate per-month statistics for people
#
import sys, datetime
class CSVStat:
def __init__ (self, name, employer, date):
self.name = name
self.employer = employer
self.added = self.removed = 0
self.date = date
def accumulate (self, p):
self.added = self.added + p.added
self.removed = self.removed + p.removed
PeriodCommitHash = { }
def AccumulatePatch (p):
date = "%.2d-%.2d-01"%(p.date.year, p.date.month)
authdatekey = "%s-%s"%(p.author.name, date)
if authdatekey not in PeriodCommitHash:
empl = p.author.emailemployer (p.email, p.date)
stat = CSVStat (p.author.name, empl, date)
PeriodCommitHash[authdatekey] = stat
else:
stat = PeriodCommitHash[authdatekey]
stat.accumulate (p)
def OutputCSV (file):
if file is None:
return
file.write ("Name\tAffliation\tDate\tAdded\tRemoved\n")
for date, stat in PeriodCommitHash.items():
# sanitise names " is common and \" sometimes too
empl_name = stat.employer.name.replace ("\"", ".").replace ("\\", ".")
author_name = stat.name.replace ("\"", ".").replace ("\\", ".")
file.write ("\"%s\"\t\"%s\"\t%s\t%d\t%d\n"%(author_name, empl_name, stat.date, \
stat.added, stat.removed))