From 74246c2c5b48a0a0cabcb79b01d46acd0621d428 Mon Sep 17 00:00:00 2001 From: GRiker Date: Tue, 26 Jan 2010 09:47:04 -0700 Subject: [PATCH] added author_to_author_sort when author_sort missing --- src/calibre/library/catalog.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index d6b5f985f7..18568703df 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -840,7 +840,7 @@ class EPUB_MOBI(CatalogPlugin): this_title['title_sort'] = self.generateSortTitle(title) this_title['author'] = " & ".join(record['authors']) this_title['author_sort'] = record['author_sort'] if len(record['author_sort']) \ - else this_title['author'] + else self.author_to_author_sort(this_title['author']) this_title['id'] = record['id'] if record['publisher']: this_title['publisher'] = re.sub('&', '&', record['publisher']) @@ -1983,6 +1983,14 @@ class EPUB_MOBI(CatalogPlugin): outfile.write(self.ncxSoup.prettify()) # Helpers + def author_to_author_sort(self, author): + tokens = author.split() + tokens = tokens[-1:] + tokens[:-1] + if len(tokens) > 1: + tokens[0] += ',' + return ' '.join(tokens) + + def convertHTMLEntities(self, s): matches = re.findall("&#\d+;", s) if len(matches) > 0: