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.
|
for a particular device.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os, re, time, json, uuid
|
import os, re, time, json, uuid, functools
|
||||||
from itertools import cycle
|
from itertools import cycle
|
||||||
|
|
||||||
from calibre.constants import numeric_version
|
from calibre.constants import numeric_version
|
||||||
@ -372,15 +372,21 @@ class USBMS(CLI, Device):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def build_template_regexp(cls):
|
def build_template_regexp(cls):
|
||||||
def replfunc(match):
|
def replfunc(match, seen=None):
|
||||||
if match.group(1) in ['title', 'series', 'series_index', 'isbn']:
|
v = match.group(1)
|
||||||
return '(?P<' + match.group(1) + '>.+?)'
|
if v in ['title', 'series', 'series_index', 'isbn']:
|
||||||
elif match.group(1) in ['authors', 'author_sort']:
|
if v not in seen:
|
||||||
return '(?P<author>.+?)'
|
seen |= set([v])
|
||||||
else:
|
return '(?P<' + v + '>.+?)'
|
||||||
return '(.+?)'
|
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]
|
template = cls.save_template().rpartition('/')[2]
|
||||||
return re.compile(re.sub('{([^}]*)}', replfunc, template) + '([_\d]*$)')
|
return re.compile(re.sub('{([^}]*)}', f, template) + '([_\d]*$)')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def path_to_unicode(cls, path):
|
def path_to_unicode(cls, path):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user