From 50b621397ee2d3919498b6847be333b7d4e23e64 Mon Sep 17 00:00:00 2001 From: David Forrester Date: Thu, 5 Dec 2013 10:48:04 +1100 Subject: [PATCH] Kobo driver: Allow sending kepubs to older kobo devices as well Refactor the code to allow sending kepubs to the older devices as well. Fixes #1257972 [Move sending kepubs from KOBOTOUCH to KOBO driver](https://bugs.launchpad.net/calibre/+bug/1257972) --- src/calibre/devices/kobo/driver.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index c2a8b6f461..a917cf7ad4 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -77,7 +77,7 @@ class KOBO(USBMS): book_class = Book # Ordered list of supported formats - FORMATS = ['epub', 'pdf', 'txt', 'cbz', 'cbr'] + FORMATS = ['kepub', 'epub', 'pdf', 'txt', 'cbz', 'cbr'] CAN_SET_METADATA = ['collections'] VENDOR_ID = [0x2237] @@ -384,6 +384,17 @@ class KOBO(USBMS): self.report_progress(1.0, _('Getting list of books on device...')) return bl + def filename_callback(self, path, mi): +# debug_print("Kobo:filename_callback:Path - {0}".format(path)) + + idx = path.rfind('.') + ext = path[idx:] + if ext == KEPUB_EXT: + path = path + EPUB_EXT +# debug_print("Kobo:filename_callback:New path - {0}".format(path)) + + return path + def delete_via_sql(self, ContentID, ContentType): # Delete Order: # 1) shortcover_page @@ -1260,7 +1271,6 @@ class KOBOTOUCH(KOBO): min_fwversion_images_tree = (2, 9, 0) # Cover images stored in tree under .kobo-images has_kepubs = True - FORMATS = ['kepub', 'epub', 'cbr', 'cbz', 'pdf', 'txt'] booklist_class = KTCollectionsBookList book_class = Book @@ -1985,17 +1995,6 @@ class KOBOTOUCH(KOBO): return True - def filename_callback(self, path, mi): -# debug_print("KoboTouch:filename_callback:Path - {0}".format(path)) - - idx = path.rfind('.') - ext = path[idx:] - if ext == KEPUB_EXT: - path = path + EPUB_EXT -# debug_print("KoboTouch:filename_callback:New path - {0}".format(path)) - - return path - def delete_via_sql(self, ContentID, ContentType): imageId = super(KOBOTOUCH, self).delete_via_sql(ContentID, ContentType)