mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #9395: Ondevice status not updated, regenerated
This commit is contained in:
parent
c62ad45810
commit
2f6a09e10e
@ -10,7 +10,7 @@ driver. It is intended to be subclassed with the relevant parts implemented
|
||||
for a particular device.
|
||||
'''
|
||||
|
||||
import os, re, time, json, uuid
|
||||
import os, re, time, json, uuid, functools
|
||||
from itertools import cycle
|
||||
|
||||
from calibre.constants import numeric_version
|
||||
@ -372,15 +372,21 @@ class USBMS(CLI, Device):
|
||||
|
||||
@classmethod
|
||||
def build_template_regexp(cls):
|
||||
def replfunc(match):
|
||||
if match.group(1) in ['title', 'series', 'series_index', 'isbn']:
|
||||
return '(?P<' + match.group(1) + '>.+?)'
|
||||
elif match.group(1) in ['authors', 'author_sort']:
|
||||
return '(?P<author>.+?)'
|
||||
else:
|
||||
return '(.+?)'
|
||||
def replfunc(match, seen=None):
|
||||
v = match.group(1)
|
||||
if v in ['title', 'series', 'series_index', 'isbn']:
|
||||
if v not in seen:
|
||||
seen |= set([v])
|
||||
return '(?P<' + v + '>.+?)'
|
||||
elif v in ['authors', 'author_sort']:
|
||||
if v not in seen:
|
||||
seen |= set([v])
|
||||
return '(?P<author>.+?)'
|
||||
return '(.+?)'
|
||||
s = set()
|
||||
f = functools.partial(replfunc, seen=s)
|
||||
template = cls.save_template().rpartition('/')[2]
|
||||
return re.compile(re.sub('{([^}]*)}', replfunc, template) + '([_\d]*$)')
|
||||
return re.compile(re.sub('{([^}]*)}', f, template) + '([_\d]*$)')
|
||||
|
||||
@classmethod
|
||||
def path_to_unicode(cls, path):
|
||||
|
Loading…
x
Reference in New Issue
Block a user