2 # A new home for the reporting code.
16 def SetHTMLOutput (file):
31 # HTML output support stuff.
34 HClasses
= ['Even', 'Odd']
38 <tr><th colspan=3>%s</th></tr>
41 def BeginReport (title
):
44 Outfile
.write ('\n%s\n' % title
)
46 HTMLfile
.write (THead
% title
)
49 TRow
= ''' <tr class="%s">
50 <td>%s</td><td align="right">%d</td><td align="right">%.1f%%</td></tr>
53 def ReportLine (text
, count
, pct
):
57 Outfile
.write ('%-25s %4d (%.1f%%)\n' % (text
, count
, pct
))
59 HTMLfile
.write (TRow
% (HClasses
[HTMLclass
], text
, count
, pct
))
64 HTMLfile
.write ('</table>\n\n')
67 # Comparison and report generation functions.
69 def ComparePCount (h1
, h2
):
70 return len (h2
.patches
) - len (h1
.patches
)
72 def ReportByPCount (hlist
, cscount
):
73 hlist
.sort (ComparePCount
)
75 BeginReport ('Developers with the most changesets')
77 pcount
= len (h
.patches
)
78 changed
= max(h
.added
, h
.removed
)
79 delta
= h
.added
- h
.removed
81 ReportLine (h
.name
, pcount
, (pcount
*100.0)/cscount
)
83 if count
>= ListCount
:
87 def CompareLChanged (h1
, h2
):
88 return max(h2
.added
, h2
.removed
) - max(h1
.added
, h1
.removed
)
90 def ReportByLChanged (hlist
, totalchanged
):
91 hlist
.sort (CompareLChanged
)
93 BeginReport ('Developers with the most changed lines')
95 pcount
= len (h
.patches
)
96 changed
= max(h
.added
, h
.removed
)
97 delta
= h
.added
- h
.removed
98 if (h
.added
+ h
.removed
) > 0:
99 ReportLine (h
.name
, changed
, (changed
*100.0)/totalchanged
)
101 if count
>= ListCount
:
105 def CompareLRemoved (h1
, h2
):
106 return (h2
.removed
- h2
.added
) - (h1
.removed
- h1
.added
)
108 def ReportByLRemoved (hlist
, totalremoved
):
109 hlist
.sort (CompareLRemoved
)
111 BeginReport ('Developers with the most lines removed')
113 pcount
= len (h
.patches
)
114 changed
= max(h
.added
, h
.removed
)
115 delta
= h
.added
- h
.removed
117 ReportLine (h
.name
, -delta
, (-delta
*100.0)/totalremoved
)
119 if count
>= ListCount
:
123 def CompareEPCount (e1
, e2
):
124 return e2
.count
- e1
.count
126 def ReportByPCEmpl (elist
, cscount
):
127 elist
.sort (CompareEPCount
)
129 BeginReport ('Top changeset contributors by employer')
132 ReportLine (e
.name
, e
.count
, (e
.count
*100.0)/cscount
)
134 if count
>= ListCount
:
140 def CompareELChanged (e1
, e2
):
141 return e2
.changed
- e1
.changed
143 def ReportByELChanged (elist
, totalchanged
):
144 elist
.sort (CompareELChanged
)
146 BeginReport ('Top lines changed by employer')
149 ReportLine (e
.name
, e
.changed
, (e
.changed
*100.0)/totalchanged
)
151 if count
>= ListCount
:
157 def CompareSOBs (h1
, h2
):
158 return len (h2
.signoffs
) - len (h1
.signoffs
)
160 def ReportBySOBs (hlist
):
161 hlist
.sort (CompareSOBs
)
164 totalsobs
+= len (h
.signoffs
)
166 BeginReport ('Developers with the most signoffs (total %d)' % totalsobs
)
168 scount
= len (h
.signoffs
)
170 ReportLine (h
.name
, scount
, (scount
*100.0)/totalsobs
)
172 if count
>= ListCount
:
177 # Reviewer reporting.
179 def CompareRevs (h1
, h2
):
180 return len (h2
.reviews
) - len (h1
.reviews
)
182 def ReportByRevs (hlist
):
183 hlist
.sort (CompareRevs
)
186 totalrevs
+= len (h
.reviews
)
188 BeginReport ('Developers with the most reviews (total %d)' % totalrevs
)
190 scount
= len (h
.reviews
)
192 ReportLine (h
.name
, scount
, (scount
*100.0)/totalrevs
)
194 if count
>= ListCount
:
201 def CompareTests (h1
, h2
):
202 return len (h2
.tested
) - len (h1
.tested
)
204 def ReportByTests (hlist
):
205 hlist
.sort (CompareTests
)
208 totaltests
+= len (h
.tested
)
210 BeginReport ('Developers with the most test credits (total %d)' % totaltests
)
212 scount
= len (h
.tested
)
214 ReportLine (h
.name
, scount
, (scount
*100.0)/totaltests
)
216 if count
>= ListCount
:
220 def CompareTestCred (h1
, h2
):
221 return h2
.testcred
- h1
.testcred
223 def ReportByTestCreds (hlist
):
224 hlist
.sort (CompareTestCred
)
227 totaltests
+= h
.testcred
229 BeginReport ('Developers who gave the most tested-by credits (total %d)' % totaltests
)
232 ReportLine (h
.name
, h
.testcred
, (h
.testcred
*100.0)/totaltests
)
234 if count
>= ListCount
:
241 # Reporter reporting.
243 def CompareReports (h1
, h2
):
244 return len (h2
.reports
) - len (h1
.reports
)
246 def ReportByReports (hlist
):
247 hlist
.sort (CompareReports
)
250 totalreps
+= len (h
.reports
)
252 BeginReport ('Developers with the most report credits (total %d)' % totalreps
)
254 scount
= len (h
.reports
)
256 ReportLine (h
.name
, scount
, (scount
*100.0)/totalreps
)
258 if count
>= ListCount
:
262 def CompareRepCred (h1
, h2
):
263 return h2
.repcred
- h1
.repcred
265 def ReportByRepCreds (hlist
):
266 hlist
.sort (CompareRepCred
)
269 totalreps
+= h
.repcred
271 BeginReport ('Developers who gave the most report credits (total %d)' % totalreps
)
274 ReportLine (h
.name
, h
.repcred
, (h
.repcred
*100.0)/totalreps
)
276 if count
>= ListCount
:
282 def CompareESOBs (e1
, e2
):
283 return e2
.sobs
- e1
.sobs
285 def ReportByESOBs (elist
):
286 elist
.sort (CompareESOBs
)
291 BeginReport ('Employers with the most signoffs (total %d)' % totalsobs
)
294 ReportLine (e
.name
, e
.sobs
, (e
.sobs
*100.0)/totalsobs
)
296 if count
>= ListCount
:
301 def DevReports (hlist
, totalchanged
, cscount
, totalremoved
):
302 ReportByPCount (hlist
, cscount
)
303 ReportByLChanged (hlist
, totalchanged
)
304 ReportByLRemoved (hlist
, totalremoved
)
307 ReportByTests (hlist
)
308 ReportByTestCreds (hlist
)
309 ReportByReports (hlist
)
310 ReportByRepCreds (hlist
)
312 def EmplReports (elist
, totalchanged
, cscount
):
313 ReportByPCEmpl (elist
, cscount
)
314 ReportByELChanged (elist
, totalchanged
)
315 ReportByESOBs (elist
)