From e3fb323d861b29a9248dffeeb83d6ce5edb3d230 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 4 Nov 2010 14:11:13 -0600 Subject: [PATCH] Fix #7403 (ZeroDivisionError: float division) --- src/calibre/ebooks/conversion/preprocess.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index bb8bf596d0..b6b218e052 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -144,7 +144,10 @@ class DocAnalysis(object): # Normalize the histogram into percents totalLines = len(self.lines) - h = [ float(count)/totalLines for count in hRaw ] + if totalLines > 0: + h = [ float(count)/totalLines for count in hRaw ] + else: + h = [] #print "\nhRaw histogram lengths are: "+str(hRaw) #print " percents are: "+str(h)+"\n"