Catch ZeroDivisionError in file extension stats.
Otherwise it would not be possible to generate stats for binary-only repositories.
This commit is contained in:
parent
75b53209da
commit
2e1aba41e9
6
gitstats
6
gitstats
@ -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>')
|
||||
|
Loading…
x
Reference in New Issue
Block a user