mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
EPUB 3 metadata: Fix updating metadata in EPUB 3 files not overwriting existing authors. Fixes #1602227 [Polish Epub3 - proliferation of dc:creator, dc:contributor](https://bugs.launchpad.net/calibre/+bug/1602227)
This commit is contained in:
parent
6cd282bced
commit
57c3a2d6af
@ -421,7 +421,7 @@ def set_authors(root, prefixes, refines, authors):
|
|||||||
for item in XPath('./opf:metadata/dc:creator')(root):
|
for item in XPath('./opf:metadata/dc:creator')(root):
|
||||||
props = properties_for_id_with_scheme(item.get('id'), prefixes, refines)
|
props = properties_for_id_with_scheme(item.get('id'), prefixes, refines)
|
||||||
opf_role = item.get(OPF('role'))
|
opf_role = item.get(OPF('role'))
|
||||||
if (is_relators_role(props, 'aut')) or (opf_role and opf_role.lower() != 'aut'):
|
if (opf_role and opf_role.lower() != 'aut') or (props.get('role') and not is_relators_role(props, 'aut')):
|
||||||
continue
|
continue
|
||||||
remove_element(item, refines)
|
remove_element(item, refines)
|
||||||
metadata = XPath('./opf:metadata')(root)[0]
|
metadata = XPath('./opf:metadata')(root)[0]
|
||||||
@ -457,7 +457,7 @@ def set_book_producers(root, prefixes, refines, producers):
|
|||||||
for item in XPath('./opf:metadata/dc:contributor')(root):
|
for item in XPath('./opf:metadata/dc:contributor')(root):
|
||||||
props = properties_for_id_with_scheme(item.get('id'), prefixes, refines)
|
props = properties_for_id_with_scheme(item.get('id'), prefixes, refines)
|
||||||
opf_role = item.get(OPF('role'))
|
opf_role = item.get(OPF('role'))
|
||||||
if (is_relators_role(props, 'bkp')) or (opf_role and opf_role.lower() != 'bkp'):
|
if (opf_role and opf_role.lower() != 'bkp') or (props.get('role') and not is_relators_role(props, 'bkp')):
|
||||||
continue
|
continue
|
||||||
remove_element(item, refines)
|
remove_element(item, refines)
|
||||||
metadata = XPath('./opf:metadata')(root)[0]
|
metadata = XPath('./opf:metadata')(root)[0]
|
||||||
|
@ -141,6 +141,9 @@ class TestOPF3(unittest.TestCase):
|
|||||||
authors = [Author('x y', 'y, x'), Author('u i', None)]
|
authors = [Author('x y', 'y, x'), Author('u i', None)]
|
||||||
self.ae(authors, st(root, authors))
|
self.ae(authors, st(root, authors))
|
||||||
self.ae(root.get('prefix'), 'calibre: %s' % CALIBRE_PREFIX)
|
self.ae(root.get('prefix'), 'calibre: %s' % CALIBRE_PREFIX)
|
||||||
|
root = self.get_opf('''<dc:creator>a b</dc:creator><dc:creator opf:role="aut">c d</dc:creator>''')
|
||||||
|
self.ae([Author('c d', None)], rl(root))
|
||||||
|
self.ae(authors, st(root, authors))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def test_book_producer(self): # {{{
|
def test_book_producer(self): # {{{
|
||||||
@ -155,7 +158,7 @@ class TestOPF3(unittest.TestCase):
|
|||||||
self.ae(['c d'], rl(root))
|
self.ae(['c d'], rl(root))
|
||||||
root = self.get_opf('''<dc:contributor>a b</dc:contributor><dc:contributor opf:role="bkp">c d</dc:contributor>''')
|
root = self.get_opf('''<dc:contributor>a b</dc:contributor><dc:contributor opf:role="bkp">c d</dc:contributor>''')
|
||||||
self.ae(['c d'], rl(root))
|
self.ae(['c d'], rl(root))
|
||||||
self.ae('12'.split(), st(root, '12'.split()))
|
self.ae(['12'], st(root, ['12']))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def test_dates(self): # {{{
|
def test_dates(self): # {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user