mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
SONY driver: Set the titleSorter attribute in the XML cache
This commit is contained in:
parent
02c3d52c3e
commit
23b67eb3b1
@ -16,7 +16,8 @@ from calibre import prints, guess_type
|
|||||||
from calibre.devices.errors import DeviceError
|
from calibre.devices.errors import DeviceError
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
from calibre.ebooks.chardet import xml_to_unicode
|
from calibre.ebooks.chardet import xml_to_unicode
|
||||||
from calibre.ebooks.metadata import string_to_authors, authors_to_string
|
from calibre.ebooks.metadata import string_to_authors, authors_to_string, \
|
||||||
|
title_sort
|
||||||
|
|
||||||
# Utility functions {{{
|
# Utility functions {{{
|
||||||
EMPTY_CARD_CACHE = '''\
|
EMPTY_CARD_CACHE = '''\
|
||||||
@ -344,7 +345,7 @@ class XMLCache(object):
|
|||||||
# *should* never happen
|
# *should* never happen
|
||||||
if DEBUG and None in records:
|
if DEBUG and None in records:
|
||||||
prints('WARNING: Some elements in the JSON cache were not'
|
prints('WARNING: Some elements in the JSON cache were not'
|
||||||
'found in the XML cache')
|
' found in the XML cache')
|
||||||
records = [x for x in records if x is not None]
|
records = [x for x in records if x is not None]
|
||||||
for rec in records:
|
for rec in records:
|
||||||
if rec.get('id', None) is None:
|
if rec.get('id', None) is None:
|
||||||
@ -413,6 +414,10 @@ class XMLCache(object):
|
|||||||
record.set('date', date)
|
record.set('date', date)
|
||||||
record.set('size', str(os.stat(path).st_size))
|
record.set('size', str(os.stat(path).st_size))
|
||||||
record.set('title', book.title)
|
record.set('title', book.title)
|
||||||
|
ts = book.title_sort
|
||||||
|
if not ts:
|
||||||
|
ts = title_sort(book.title)
|
||||||
|
record.set('titleSorter', ts)
|
||||||
record.set('author', authors_to_string(book.authors))
|
record.set('author', authors_to_string(book.authors))
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext:
|
if ext:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user