From 552f7e9421c0216faca30e4039618baf4938cb79 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Fri, 20 Aug 2010 17:31:16 +0100 Subject: [PATCH] Possible fix for use_author_sort being ignored sometimes --- src/calibre/devices/prs505/sony_cache.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/prs505/sony_cache.py b/src/calibre/devices/prs505/sony_cache.py index a444c9e5e2..5f3e9118dc 100644 --- a/src/calibre/devices/prs505/sony_cache.py +++ b/src/calibre/devices/prs505/sony_cache.py @@ -15,7 +15,8 @@ from calibre.devices.errors import DeviceError from calibre.devices.usbms.driver import debug_print from calibre.constants import DEBUG, preferred_encoding from calibre.ebooks.chardet import xml_to_unicode -from calibre.ebooks.metadata import authors_to_string, title_sort +from calibre.ebooks.metadata import authors_to_string, title_sort, \ + authors_to_sort_string # Utility functions {{{ EMPTY_CARD_CACHE = '''\ @@ -509,8 +510,13 @@ class XMLCache(object): if not ts: ts = title_sort(title) record.set('titleSorter', clean(ts)) - if self.use_author_sort and book.author_sort is not None: - record.set('author', clean(book.author_sort)) + if self.use_author_sort: + if book.author_sort: + aus = book.author_sort + else: + debug_print('Author_sort is None for book', book.lpath) + aus = authors_to_sort_string(book.authors) + record.set('author', clean(aus)) else: record.set('author', clean(authors_to_string(book.authors))) ext = os.path.splitext(path)[1]