From fcb38b81cfab1f435363d13bb017e816baae7dc4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 15 Feb 2022 12:14:39 +0100 Subject: [PATCH] fix loading of unused chars in xml format --- openpype/lib/transcoding.py | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/openpype/lib/transcoding.py b/openpype/lib/transcoding.py index 36f6858a78..5caea32ee1 100644 --- a/openpype/lib/transcoding.py +++ b/openpype/lib/transcoding.py @@ -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")