From e24adc0e35c288f2155bd3147b226ec9b5d494bc Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 10 Apr 2012 18:16:42 +0200 Subject: [PATCH] Prevent exceptions when 1) both author and author_sort are used in "add" templates, and 2) books are added from a device, and 3) read metadata from file contents is not checked. --- src/calibre/devices/usbms/driver.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index 17e131a76b..a5ab0bd15c 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -402,14 +402,12 @@ class USBMS(CLI, Device): def build_template_regexp(cls): def replfunc(match, seen=None): v = match.group(1) - if v in ['title', 'series', 'series_index', 'isbn']: + if v in ['authors', 'author_sort']: + v = 'author' + if v in ('title', 'series', 'series_index', 'isbn', 'author'): if v not in seen: - seen |= set([v]) + seen.add(v) return '(?P<' + v + '>.+?)' - elif v in ['authors', 'author_sort']: - if v not in seen: - seen |= set([v]) - return '(?P.+?)' return '(.+?)' s = set() f = functools.partial(replfunc, seen=s)