mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use regex rather then explicit values
This commit is contained in:
parent
fcb38b81cf
commit
7e1203ea51
1 changed files with 10 additions and 35 deletions
|
|
@ -31,37 +31,9 @@ INT_TAGS = {
|
|||
"subimages",
|
||||
}
|
||||
|
||||
XML_UNUSED_CHARS = {
|
||||
"�",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
}
|
||||
CHAR_REF_REGEX_DECIMAL = re.compile(r"&#[0-9]+;")
|
||||
CHAR_REF_REGEX_HEX = re.compile(r"&#x[0-9a-zA-Z]+;")
|
||||
|
||||
# Regex to parse array attributes
|
||||
ARRAY_TYPE_REGEX = re.compile(r"^(int|float|string)\[\d+\]$")
|
||||
|
||||
|
|
@ -226,10 +198,13 @@ def parse_oiio_xml_output(xml_string, logger=None):
|
|||
# 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)
|
||||
matches = (
|
||||
set(CHAR_REF_REGEX_HEX.findall(xml_string))
|
||||
| set(CHAR_REF_REGEX_DECIMAL.findall(xml_string))
|
||||
)
|
||||
for match in matches:
|
||||
new_value = match.replace("&", "&")
|
||||
xml_string = xml_string.replace(match, new_value)
|
||||
|
||||
if logger is None:
|
||||
logger = logging.getLogger("OIIO-xml-parse")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue