From 2baaf359249b07944a7c475ef99da1afd923b613 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 24 Oct 2011 20:37:05 -0400 Subject: [PATCH] Fix bug #880930: Fix rb format compression. --- src/calibre/ebooks/rb/writer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/rb/writer.py b/src/calibre/ebooks/rb/writer.py index f71b103fbd..fc73d25b2d 100644 --- a/src/calibre/ebooks/rb/writer.py +++ b/src/calibre/ebooks/rb/writer.py @@ -104,8 +104,9 @@ class RBWriter(object): size = len(text) pages = [] - for i in range(0, (len(text) / TEXT_RECORD_SIZE) + 1): - pages.append(zlib.compress(text[i * TEXT_RECORD_SIZE : (i * TEXT_RECORD_SIZE) + TEXT_RECORD_SIZE], 9)) + for i in range(0, (len(text) + TEXT_RECORD_SIZE-1) / TEXT_RECORD_SIZE): + zobj = zlib.compressobj(9, zlib.DEFLATED, 13, 8, 0) + pages.append(zobj.compress(text[i * TEXT_RECORD_SIZE : (i * TEXT_RECORD_SIZE) + TEXT_RECORD_SIZE]) + zobj.flush()) return (size, pages)