[BACKEND] Use native xml library, remove dicttoxml

This commit is contained in:
Jesse Bannon 2022-08-26 22:57:21 -07:00
parent 553862fdad
commit 55ee0fe833
2 changed files with 8 additions and 9 deletions

View file

@ -26,7 +26,6 @@ packages=find:
install_requires = install_requires =
yt-dlp yt-dlp
argparse==1.4.0 argparse==1.4.0
dicttoxml==1.7.4
mergedeep==1.3.4 mergedeep==1.3.4
mediafile==0.9.0 mediafile==0.9.0
PyYAML==6.0 PyYAML==6.0

View file

@ -1,6 +1,6 @@
from typing import Dict from typing import Dict
import dicttoxml import xml.etree.ElementTree as et
def _to_max_3_byte_utf8_char(char: str) -> str: def _to_max_3_byte_utf8_char(char: str) -> str:
@ -38,7 +38,7 @@ def to_max_3_byte_utf8_dict(string_dict: Dict[str, str]) -> Dict[str, str]:
} }
def to_xml(nfo_dict: Dict[str, str], nfo_root: str) -> bytes: def to_xml(nfo_dict: Dict[str, str], nfo_root: str) -> str:
""" """
Transforms a dict to XML Transforms a dict to XML
@ -53,9 +53,9 @@ def to_xml(nfo_dict: Dict[str, str], nfo_root: str) -> bytes:
------- -------
XML bytes XML bytes
""" """
return dicttoxml.dicttoxml( xml_root = et.Element(nfo_root)
obj=nfo_dict, for key, value in nfo_dict.items():
root=True, et.SubElement(xml_root, value)
custom_root=nfo_root,
attr_type=False, return et.tostring(element=xml_root, encoding='utf-8', xml_declaration=True)
)