Some packages (ex: skeleton-init-systemd) have a zero size so we cannot
divide by the package size. In that case make their percent zero
explicitly and avoid a ZeroDivisionError exception.
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Acked-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
"File size in system (%)"])
for f, (pkgname, filesize) in filesdict.items():
pkgsize = pkgsizes[pkgname]
+
+ if pkgsize == 0:
+ percent_pkg = 0
+ else:
+ percent_pkg = float(filesize) / pkgsize * 100
+
+ percent_total = float(filesize) / total * 100
+
wr.writerow([f, pkgname, filesize, pkgsize,
- "%.1f" % (float(filesize) / pkgsize * 100),
- "%.1f" % (float(filesize) / total * 100)])
+ "%.1f" % percent_pkg,
+ "%.1f" % percent_total])
#