mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB metadata: When setting metadata in an EPUB, explicitly specify the namespace of the role attribute on the <dc:creator> tag
This commit is contained in:
parent
a83f930b92
commit
5399e417da
@ -792,19 +792,16 @@ class OPF(object): # {{{
|
||||
remove = list(self.authors_path(self.metadata))
|
||||
for elem in remove:
|
||||
elem.getparent().remove(elem)
|
||||
elems = []
|
||||
for author in val:
|
||||
attrib = {'{%s}role'%self.NAMESPACES['opf']: 'aut'}
|
||||
elem = self.create_metadata_element('creator', attrib=attrib)
|
||||
# Ensure new author element is at the top of the list
|
||||
# for broken implementations that always use the first
|
||||
# <dc:creator> element with no attention to the role
|
||||
for author in reversed(val):
|
||||
elem = self.metadata.makeelement('{%s}creator'%
|
||||
self.NAMESPACES['dc'], nsmap=self.NAMESPACES)
|
||||
elem.tail = '\n'
|
||||
self.metadata.insert(0, elem)
|
||||
elem.set('{%s}role'%self.NAMESPACES['opf'], 'aut')
|
||||
self.set_text(elem, author.strip())
|
||||
# Ensure new author element is at the top of the list
|
||||
# for broken implementations that always use the first
|
||||
# <dc:creator> element with no attention to the role
|
||||
elems.append(elem)
|
||||
for elem in reversed(elems):
|
||||
parent = elem.getparent()
|
||||
parent.remove(elem)
|
||||
parent.insert(0, elem)
|
||||
|
||||
return property(fget=fget, fset=fset)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user