mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use single regex
This commit is contained in:
parent
7e1203ea51
commit
646eb2e519
1 changed files with 3 additions and 7 deletions
|
|
@ -31,8 +31,7 @@ INT_TAGS = {
|
||||||
"subimages",
|
"subimages",
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAR_REF_REGEX_DECIMAL = re.compile(r"&#[0-9]+;")
|
XML_CHAR_REF_REGEX_HEX = re.compile(r"&#x?[0-9a-fA-F]+;")
|
||||||
CHAR_REF_REGEX_HEX = re.compile(r"&#x[0-9a-zA-Z]+;")
|
|
||||||
|
|
||||||
# Regex to parse array attributes
|
# Regex to parse array attributes
|
||||||
ARRAY_TYPE_REGEX = re.compile(r"^(int|float|string)\[\d+\]$")
|
ARRAY_TYPE_REGEX = re.compile(r"^(int|float|string)\[\d+\]$")
|
||||||
|
|
@ -196,12 +195,9 @@ def parse_oiio_xml_output(xml_string, logger=None):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# Fix values with ampresand (lazy fix)
|
# Fix values with ampresand (lazy fix)
|
||||||
# - ElementTree can't handle all escaped values with ampresand
|
# - oiiotool exports invalid xml which ElementTree can't handle
|
||||||
# e.g. ""
|
# e.g. ""
|
||||||
matches = (
|
matches = XML_CHAR_REF_REGEX_HEX.findall(xml_string)
|
||||||
set(CHAR_REF_REGEX_HEX.findall(xml_string))
|
|
||||||
| set(CHAR_REF_REGEX_DECIMAL.findall(xml_string))
|
|
||||||
)
|
|
||||||
for match in matches:
|
for match in matches:
|
||||||
new_value = match.replace("&", "&")
|
new_value = match.replace("&", "&")
|
||||||
xml_string = xml_string.replace(match, new_value)
|
xml_string = xml_string.replace(match, new_value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue