참고소스 수정본

This commit is contained in:
LASTA_DEV01\lasta
2026-05-12 19:40:31 +09:00
parent 0f34a451fc
commit 2e9204243d
8708 changed files with 3259488 additions and 869 deletions

View File

@@ -0,0 +1,37 @@
from typing import Optional, Union, cast
# TODO: Remove after DataTypes and ValidatorsAttr is removed
def cast_xml_to_string(xml_value: Union[memoryview, bytes, bytearray, str]) -> str:
"""Cast XML value to a string.
Args:
xml_value (Union[memoryview, bytes, bytearray, str]): The XML value to cast.
Returns:
str: The XML value as a string.
"""
return cast(str, xml_to_string(xml_value))
def xml_to_string(
xml: Optional[Union[memoryview, bytes, bytearray, str]],
) -> Optional[str]:
"""Convert XML value to a string.
Args:
xml_value (Union[memoryview, bytes, bytearray, str]): The XML value to cast.
Returns:
str: The XML value as a string.
"""
if xml is None:
return None
string = xml
if isinstance(xml, memoryview):
string = xml.tobytes().decode()
elif isinstance(xml, (bytes, bytearray)):
string = xml.decode()
return cast(str, string)