diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 3e87f12255..835ab0219e 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -31,8 +31,6 @@ from calibre.utils.config_base import prefs EPUB_EXT = '.epub' KEPUB_EXT = '.kepub' -USE_SQLITE3 = False - # Implementation of QtQHash for strings. This doesn't seem to be in the Python implementation. def qhash(inputstr): instr = b"" @@ -159,15 +157,8 @@ class KOBO(USBMS): return self.normalize_path(self._main_prefix + '.kobo/KoboReader.sqlite') def device_database_connection(self): - if USE_SQLITE3: - import sqlite3 as sqlite - db_connection = sqlite.connect(self.device_database_path()) - - # return bytestrings if the content cannot the decoded as unicode - db_connection.text_factory = lambda x: unicode(x, "utf-8", "ignore") - else: - import apsw - db_connection = apsw.Connection(self.device_database_path()) + import apsw + db_connection = apsw.Connection(self.device_database_path()) return db_connection @@ -1378,20 +1369,20 @@ class KOBOTOUCH(KOBO): ' - N3_LIBRARY_FULL.parsed':[(355,473),0, 200,False,], # Used for Details screen before FW2.8.1, then for current book tile on home screen ' - N3_LIBRARY_GRID.parsed':[(149,198),0, 200,False,], # Used for library lists ' - N3_LIBRARY_LIST.parsed':[(60,90),0, 53,False,], - ' - AndroidBookLoadTablet_Aspect.parsed':[(355,473), 82, 200,False,], # Used for Details screen from FW2.8.1 + ' - AndroidBookLoadTablet_Aspect.parsed':[(355,473), 82, 100,False,], # Used for Details screen from FW2.8.1 # ' - N3_LIBRARY_SHELF.parsed': [(40,60),0, 52,], } GLO_COVER_FILE_ENDINGS = { # Glo and Aura share resolution, so the image sizes should be the same. ' - N3_FULL.parsed':[(758,1024),0, 200,True,], # Used for screensaver, home screen ' - N3_LIBRARY_FULL.parsed':[(355,479),0, 200,False,], # Used for Details screen before FW2.8.1, then for current book tile on home screen ' - N3_LIBRARY_GRID.parsed':[(149,201),0, 200,False,], # Used for library lists - ' - AndroidBookLoadTablet_Aspect.parsed':[(355,479), 88, 200,False,], # Used for Details screen from FW2.8.1 + ' - AndroidBookLoadTablet_Aspect.parsed':[(355,479), 88, 100,False,], # Used for Details screen from FW2.8.1 } AURA_HD_COVER_FILE_ENDINGS = { ' - N3_FULL.parsed': [(1080,1440), 0, 200,True,], # Used for screensaver, home screen ' - N3_LIBRARY_FULL.parsed':[(355, 471), 0, 200,False,], # Used for Details screen before FW2.8.1, then for current book tile on home screen ' - N3_LIBRARY_GRID.parsed':[(149, 198), 0, 200,False,], # Used for library lists - ' - AndroidBookLoadTablet_Aspect.parsed':[(355, 471), 88, 200,False,], # Used for Details screen from FW2.8.1 + ' - AndroidBookLoadTablet_Aspect.parsed':[(355, 471), 88, 100,False,], # Used for Details screen from FW2.8.1 } # Following are the sizes used with pre2.1.4 firmware # COVER_FILE_ENDINGS = { @@ -1846,18 +1837,18 @@ class KOBOTOUCH(KOBO): def imagefilename_from_imageID(self, prefix, ImageID): show_debug = self.is_debugging_title(ImageID) - path = self.images_path(prefix, ImageID) -# path = self.normalize_path(path.replace('/', os.sep)) - - for ending, cover_options in self.cover_file_endings().items(): - fpath = path + ending - if os.path.exists(fpath): - if show_debug: - debug_print("KoboTouch:imagefilename_from_imageID - have cover image fpath=%s" % (fpath)) - return fpath - - if show_debug: - debug_print("KoboTouch:imagefilename_from_imageID - no cover image found - ImageID=%s" % (ImageID)) + if len(ImageID) > 0: + path = self.images_path(prefix, ImageID) + + for ending in self.cover_file_endings().keys(): + fpath = path + ending + if os.path.exists(fpath): + if show_debug: + debug_print("KoboTouch:imagefilename_from_imageID - have cover image fpath=%s" % (fpath)) + return fpath + + if show_debug: + debug_print("KoboTouch:imagefilename_from_imageID - no cover image found - ImageID=%s" % (ImageID)) return None def get_extra_css(self):