mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-27 03:44:45 +01: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
1 changed files with 11 additions and 5 deletions
|
|
@ -483,11 +483,17 @@ def author(item, props, val):
|
|||
|
||||
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…
Reference in a new issue