From ad764f3cd9859e669908139a2335619c54f7a3f8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 10 Apr 2012 19:22:27 +0530 Subject: [PATCH] ... --- src/calibre/devices/usbms/driver.py | 10 ++++++++-- src/calibre/ebooks/mobi/debug/mobi8.py | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index b061bafc03..17e131a76b 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -413,8 +413,14 @@ class USBMS(CLI, Device): return '(.+?)' s = set() f = functools.partial(replfunc, seen=s) - template = cls.save_template().rpartition('/')[2] - return re.compile(re.sub('{([^}]*)}', f, template) + '([_\d]*$)') + template = None + try: + template = cls.save_template().rpartition('/')[2] + return re.compile(re.sub('{([^}]*)}', f, template) + '([_\d]*$)') + except: + prints(u'Failed to parse template: %r'%template) + template = u'{title} - {authors}' + return re.compile(re.sub('{([^}]*)}', f, template) + '([_\d]*$)') @classmethod def path_to_unicode(cls, path): diff --git a/src/calibre/ebooks/mobi/debug/mobi8.py b/src/calibre/ebooks/mobi/debug/mobi8.py index 458b2d4893..4e4fcfae57 100644 --- a/src/calibre/ebooks/mobi/debug/mobi8.py +++ b/src/calibre/ebooks/mobi/debug/mobi8.py @@ -63,7 +63,6 @@ class MOBIFile(object): self.raw_text = b''.join(r.raw for r in self.text_records) self.header = self.mf.mobi8_header - self.kf8_records = mf.records[offset:] self.extract_resources() self.read_fdst()