Catch ZeroDivisionError in file extension stats.

Otherwise it would not be possible to generate stats for binary-only
repositories.
This commit is contained in:
Heikki Hokkanen 2012-07-13 18:07:29 +03:00
parent 75b53209da
commit 2e1aba41e9

View File

@ -1050,7 +1050,11 @@ class HTMLReportCreator(ReportCreator):
for ext in sorted(data.extensions.keys()):
files = data.extensions[ext]['files']
lines = data.extensions[ext]['lines']
f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (ext, files, (100.0 * files) / data.getTotalFiles(), lines, (100.0 * lines) / data.getTotalLOC(), lines / files))
try:
loc_percentage = (100.0 * lines) / data.getTotalLOC()
except ZeroDivisionError:
loc_percentage = 0
f.write('<tr><td>%s</td><td>%d (%.2f%%)</td><td>%d (%.2f%%)</td><td>%d</td></tr>' % (ext, files, (100.0 * files) / data.getTotalFiles(), lines, loc_percentage, lines / files))
f.write('</table>')
f.write('</body></html>')