Skip to content

Commit

Permalink
AZW3 Output: Ignore invalid attribute names in the input document rat…
Browse files Browse the repository at this point in the history
…her than aborting the conversion on them.
  • Loading branch information
kovidgoyal committed Oct 16, 2014
1 parent 0e93afb commit a10c7f9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/calibre/ebooks/mobi/writer8/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,12 @@ def remove_namespaces(self, root):
tn = tag.tag
if tn is not None:
tn = tn.rpartition('}')[-1]
elem = nroot.makeelement(tn,
attrib={k.rpartition('}')[-1]:v for k, v in
tag.attrib.iteritems()})
attrib = {k.rpartition('}')[-1]:v for k, v in tag.attrib.iteritems()}
try:
elem = nroot.makeelement(tn, attrib=attrib)
except ValueError:
attrib = {k:v for k, v in attrib.iteritems() if ':' not in k}
elem = nroot.makeelement(tn, attrib=attrib)
elem.text = tag.text
elem.tail = tag.tail
parent = node_from_path(nroot, path_to_node(tag.getparent()))
Expand Down

0 comments on commit a10c7f9

Please sign in to comment.