AZW3 Output: Ignore invalid attribute names in the input document rather than aborting the conversion on them.

This commit is contained in:
Kovid Goyal 2014-10-16 08:05:29 +05:30
parent 0e93afb1e5
commit a10c7f9a35

View File

@ -237,9 +237,12 @@ class Chunker(object):
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()))