From 9943fff0b4a1a463c514bdd847f0e8146b5ed8ba Mon Sep 17 00:00:00 2001 From: David Forrester Date: Thu, 16 Oct 2014 23:50:51 +1100 Subject: [PATCH] Kobo driver: Update to support new firmware from Kobo. Fixes #1382051 [Kobo: Skip modifying epub if no valid CSS rules and bump firmware version](https://bugs.launchpad.net/calibre/+bug/1382051) Skip modifying epub if no valid CSS rules and bump firmware version While looking at a problem with the stylesheet on Kobo devices recently, I realised that if the modify CSS option was set and the was no file, it still modified the stylesheet. Now, will not do this if there are no valid rules in the kobo_extra.css file. Also bumping firmware version to 3.11.1. Kobo are about to release an update. They big jump on version number is to match the desktop application version. --- src/calibre/devices/kobo/driver.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 06e634cedb..4565d5d2af 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -68,7 +68,7 @@ class KOBO(USBMS): dbversion = 0 fwversion = 0 - supported_dbversion = 105 + supported_dbversion = 112 has_kepubs = False supported_platforms = ['windows', 'osx', 'linux'] @@ -1256,7 +1256,7 @@ class KOBOTOUCH(KOBO): description = 'Communicate with the Kobo Touch, Glo, Mini and Aura HD ereaders. Based on the existing Kobo driver by %s.' % (KOBO.author) # icon = I('devices/kobotouch.jpg') - supported_dbversion = 105 + supported_dbversion = 112 min_supported_dbversion = 53 min_dbversion_series = 65 min_dbversion_externalid = 65 @@ -1265,7 +1265,7 @@ class KOBOTOUCH(KOBO): min_dbversion_activity = 77 min_dbversion_keywords = 82 - max_supported_fwversion = (3, 8, 1) + max_supported_fwversion = (3, 11, 1) min_fwversion_shelves = (2, 0, 0) min_fwversion_images_on_sdcard = (2, 4, 1) min_fwversion_images_tree = (2, 9, 0) # Cover images stored in tree under .kobo-images @@ -1882,6 +1882,9 @@ class KOBOTOUCH(KOBO): try: extra_sheet = cssparseFile(extra_css_path) debug_print("KoboTouch:get_extra_css: Using extra CSS in {0} ({1} rules)".format(extra_css_path, len(extra_sheet.cssRules))) + if len(extra_sheet.cssRules) ==0: + debug_print("KoboTouch:get_extra_css: Extra CSS file has no valid rules. CSS will not be modified.") + extra_sheet = None except Exception as e: debug_print("KoboTouch:get_extra_css: Problem parsing extra CSS file {0}".format(extra_css_path)) debug_print("KoboTouch:get_extra_css: Exception {0}".format(e)) @@ -1946,6 +1949,7 @@ class KOBOTOUCH(KOBO): # Currently only modifying CSS, so if no stylesheet, don't do anything if not self.extra_sheet: + debug_print("KoboTouch:_modify_epub: no CSS file") return True commit_container = False