mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB 3: When setting authors and there are only editors, remove the editors. Matches EPUB 2 behavior and is symmetric with using only editors as authors when reading the metadata
This commit is contained in:
parent
5ca15b9175
commit
1e05b40f7a
@ -483,11 +483,17 @@ def read_authors(root, prefixes, refines):
|
||||
|
||||
def set_authors(root, prefixes, refines, authors):
|
||||
ensure_prefix(root, prefixes, 'marc')
|
||||
for item in XPath('./opf:metadata/dc:creator')(root):
|
||||
props = properties_for_id_with_scheme(item.get('id'), prefixes, refines)
|
||||
opf_role = item.get(OPF('role'))
|
||||
if (opf_role and opf_role.lower() != 'aut') or (props.get('role') and not is_relators_role(props, 'aut')):
|
||||
continue
|
||||
removals = []
|
||||
for role in ('aut', 'edt'):
|
||||
for item in XPath('./opf:metadata/dc:creator')(root):
|
||||
props = properties_for_id_with_scheme(item.get('id'), prefixes, refines)
|
||||
opf_role = item.get(OPF('role'))
|
||||
if (opf_role and opf_role.lower() != role) or (props.get('role') and not is_relators_role(props, role)):
|
||||
continue
|
||||
removals.append(item)
|
||||
if removals:
|
||||
break
|
||||
for item in removals:
|
||||
remove_element(item, refines)
|
||||
metadata = XPath('./opf:metadata')(root)[0]
|
||||
for author in authors:
|
||||
|
Loading…
x
Reference in New Issue
Block a user