From 9acd6d6189cdb2f008ea519fb5b0709db93c4601 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Tue, 1 Feb 2011 17:28:55 +0000 Subject: [PATCH] Put file-as back into OPF title_sort.get as a fall back --- src/calibre/ebooks/metadata/opf2.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 456bfb0ea6..a721c5cb2f 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -780,15 +780,24 @@ class OPF(object): # {{{ def title_sort(self): def fget(self): + #first try the title_sort meta tag matches = self.root.xpath('//*[name() = "meta" and starts-with(@name,' '"calibre:title_sort") and @content]') if matches: for elem in matches: return self.get_text(elem) + # fallback to file-as + matches = self.title_path(self.metadata) + if matches: + for match in matches: + ans = match.get('{%s}file-as'%self.NAMESPACES['opf'], None) + if not ans: + ans = match.get('file-as', None) + if ans: + return ans return None def fset(self, val): - print 'here' matches = self.root.xpath('//*[name() = "meta" and starts-with(@name,' '"calibre:title_sort") and @content]') if matches: