mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix for #7883: 'title_sort' field in save to disk template empty in v 7.33
This commit is contained in:
parent
fdb842b036
commit
3d3dcb3915
@ -780,22 +780,30 @@ class OPF(object): # {{{
|
|||||||
def title_sort(self):
|
def title_sort(self):
|
||||||
|
|
||||||
def fget(self):
|
def fget(self):
|
||||||
matches = self.title_path(self.metadata)
|
matches = self.root.xpath('//*[name() = "meta" and starts-with(@name,'
|
||||||
|
'"calibre:title_sort") and @content]')
|
||||||
if matches:
|
if matches:
|
||||||
for match in matches:
|
for elem in matches:
|
||||||
ans = match.get('{%s}file-as'%self.NAMESPACES['opf'], None)
|
return self.get_text(elem)
|
||||||
if not ans:
|
return None
|
||||||
ans = match.get('file-as', None)
|
|
||||||
if ans:
|
|
||||||
return ans
|
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
|
print 'here'
|
||||||
|
matches = self.root.xpath('//*[name() = "meta" and starts-with(@name,'
|
||||||
|
'"calibre:title_sort") and @content]')
|
||||||
|
if matches:
|
||||||
|
for elem in matches:
|
||||||
|
elem.getparent().remove(elem)
|
||||||
matches = self.title_path(self.metadata)
|
matches = self.title_path(self.metadata)
|
||||||
if matches:
|
if matches:
|
||||||
for key in matches[0].attrib:
|
for elem in matches:
|
||||||
if key.endswith('file-as'):
|
parent = elem.getparent()
|
||||||
matches[0].attrib.pop(key)
|
attrib = {}
|
||||||
matches[0].set('{%s}file-as'%self.NAMESPACES['opf'], unicode(val))
|
attrib['name'] = 'calibre:title_sort'
|
||||||
|
attrib['content'] = val
|
||||||
|
e = elem.makeelement('meta', attrib=attrib)
|
||||||
|
e.tail = '\n'+(' '*8)
|
||||||
|
parent.append(elem)
|
||||||
|
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user