Prevent erros when both author and author_sort are used ina template for reading metadata from filenames for files on a device

This commit is contained in:
Kovid Goyal 2012-04-10 21:51:51 +05:30
commit 055690844a

View File

@ -402,14 +402,12 @@ class USBMS(CLI, Device):
def build_template_regexp(cls): def build_template_regexp(cls):
def replfunc(match, seen=None): def replfunc(match, seen=None):
v = match.group(1) 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: if v not in seen:
seen |= set([v]) seen.add(v)
return '(?P<' + v + '>.+?)' return '(?P<' + v + '>.+?)'
elif v in ['authors', 'author_sort']:
if v not in seen:
seen |= set([v])
return '(?P<author>.+?)'
return '(.+?)' return '(.+?)'
s = set() s = set()
f = functools.partial(replfunc, seen=s) f = functools.partial(replfunc, seen=s)