mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix updating the calibre application id in EPUBs that also use the application id as the package id.
This commit is contained in:
parent
6fc800d6c6
commit
be977db0d9
@ -941,9 +941,19 @@ class OPF(object): # {{{
|
|||||||
return self.get_text(match) or None
|
return self.get_text(match) or None
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
|
removed_ids = set()
|
||||||
for x in tuple(self.application_id_path(self.metadata)):
|
for x in tuple(self.application_id_path(self.metadata)):
|
||||||
|
removed_ids.add(x.get('id', None))
|
||||||
x.getparent().remove(x)
|
x.getparent().remove(x)
|
||||||
|
|
||||||
|
uuid_id = None
|
||||||
|
for attr in self.root.attrib:
|
||||||
|
if attr.endswith('unique-identifier'):
|
||||||
|
uuid_id = self.root.attrib[attr]
|
||||||
|
break
|
||||||
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'calibre'}
|
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'calibre'}
|
||||||
|
if uuid_id and uuid_id in removed_ids:
|
||||||
|
attrib['id'] = uuid_id
|
||||||
self.set_text(self.create_metadata_element(
|
self.set_text(self.create_metadata_element(
|
||||||
'identifier', attrib=attrib), unicode(val))
|
'identifier', attrib=attrib), unicode(val))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user