From 206af4c041a905f069835bc7c8bd46cd9848aa10 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 5 Sep 2012 09:28:06 +0530 Subject: [PATCH] Device drivers: Ignore corrupted metadata.calibre, instead of raising an error --- src/calibre/devices/usbms/driver.py | 2 +- src/calibre/ebooks/metadata/book/json_codec.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index 5f6bdd9402..94309e747e 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -166,7 +166,7 @@ class USBMS(CLI, Device): # make a dict cache of paths so the lookup in the loop below is faster. bl_cache = {} - for idx,b in enumerate(bl): + for idx, b in enumerate(bl): bl_cache[b.lpath] = idx all_formats = self.formats_to_scan_for() diff --git a/src/calibre/ebooks/metadata/book/json_codec.py b/src/calibre/ebooks/metadata/book/json_codec.py index cc9b6f252d..e9cec8acc7 100644 --- a/src/calibre/ebooks/metadata/book/json_codec.py +++ b/src/calibre/ebooks/metadata/book/json_codec.py @@ -161,7 +161,9 @@ class JsonCodec(object): try: js = json.load(file_, encoding='utf-8') for item in js: - booklist.append(self.raw_to_book(item, book_class, prefix)) + entry = self.raw_to_book(item, book_class, prefix) + if entry is not None: + booklist.append(entry) except: print 'exception during JSON decode_from_file' traceback.print_exc()