2 # aggregate per-month statistics for people
7 def __init__ (self
, name
, employer
, date
):
9 self
.employer
= employer
10 self
.added
= self
.removed
= 0
12 def accumulate (self
, p
):
13 self
.added
= self
.added
+ p
.added
14 self
.removed
= self
.removed
+ p
.removed
16 PeriodCommitHash
= { }
18 def AccumulatePatch (p
):
19 date
= "%.2d-%.2d-01"%(p
.date
.year
, p
.date
.month
)
20 authdatekey
= "%s-%s"%(p
.author
.name
, date
)
21 if authdatekey
not in PeriodCommitHash
:
22 empl
= p
.author
.emailemployer (p
.email
, p
.date
)
23 stat
= CSVStat (p
.author
.name
, empl
, date
)
24 PeriodCommitHash
[authdatekey
] = stat
26 stat
= PeriodCommitHash
[authdatekey
]
32 file.write ("Name\tAffliation\tDate\tAdded\tRemoved\n")
33 for date
, stat
in PeriodCommitHash
.items():
34 # sanitise names " is common and \" sometimes too
35 empl_name
= stat
.employer
.name
.replace ("\"", ".").replace ("\\", ".")
36 author_name
= stat
.name
.replace ("\"", ".").replace ("\\", ".")
37 file.write ("\"%s\"\t\"%s\"\t%s\t%d\t%d\n"%(author_name
, empl_name
, stat
.date
, \
38 stat
.added
, stat
.removed
))