fix loading of unused chars in xml format

This commit is contained in:
Jakub Trllo 2022-02-15 12:14:39 +01:00
parent 3bc8ae4e3b
commit fcb38b81cf

View file

@ -30,6 +30,38 @@ INT_TAGS = {
"deep",
"subimages",
}
XML_UNUSED_CHARS = {
"�",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
}
# Regex to parse array attributes
ARRAY_TYPE_REGEX = re.compile(r"^(int|float|string)\[\d+\]$")
@ -191,6 +223,14 @@ def parse_oiio_xml_output(xml_string, logger=None):
if not xml_string:
return output
# Fix values with ampresand (lazy fix)
# - ElementTree can't handle all escaped values with ampresand
# e.g. ""
for unused_char in XML_UNUSED_CHARS:
if unused_char in xml_string:
new_char = unused_char.replace("&", "&")
xml_string = xml_string.replace(unused_char, new_char)
if logger is None:
logger = logging.getLogger("OIIO-xml-parse")