Book polishing: Do not error out when polishing epub files that have XML comments in their OPF metadata section.

This commit is contained in:
Kovid Goyal 2013-03-05 22:54:35 +05:30
parent ebf4068ebc
commit ac5d96f7f3

View File

@ -391,9 +391,12 @@ class Container(object):
remove = set()
for child in mdata:
child.tail = '\n '
if (child.get('name', '').startswith('calibre:') and
child.get('content', '').strip() in {'{}', ''}):
remove.add(child)
try:
if (child.get('name', '').startswith('calibre:') and
child.get('content', '').strip() in {'{}', ''}):
remove.add(child)
except AttributeError:
continue # Happens for XML comments
for child in remove: mdata.remove(child)
if len(mdata) > 0:
mdata[-1].tail = '\n '