File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 88from lxml import etree
99
1010
11- def process_xml_string (xml_string ) :
11+ def process_xml_string (xml_string : str ) -> str :
1212 """
1313 Функция из текста выдирает строку с xml --
1414 она должна начинаться на < и заканчиваться >
@@ -20,20 +20,27 @@ def process_xml_string(xml_string):
2020 return xml_string [start : end + 1 ]
2121
2222
23- def pretty_xml_minidom (xml_string , ind = 2 ) :
23+ def pretty_xml_minidom (xml_string : str , indent : int = 4 ) -> str :
2424 """Функция принимает строку xml и выводит xml с отступами."""
2525
2626 xml_string = process_xml_string (xml_string )
27- xml_utf8 = parseString (xml_string ).toprettyxml (indent = " " * ind , encoding = "utf-8" )
27+ xml_utf8 = parseString (xml_string ).toprettyxml (
28+ indent = " " * indent ,
29+ encoding = "utf-8" ,
30+ )
2831 return xml_utf8 .decode ("utf-8" )
2932
3033
31- def pretty_xml_lxml (xml_string ) :
34+ def pretty_xml_lxml (xml_string : str ) -> str :
3235 """Функция принимает строку xml и выводит xml с отступами."""
3336
3437 xml_string = process_xml_string (xml_string )
3538 root = etree .fromstring (xml_string )
36- return etree .tostring (root , pretty_print = True , encoding = "utf-8" ).decode ("utf-8" )
39+ return etree .tostring (
40+ root ,
41+ pretty_print = True ,
42+ encoding = "utf-8" ,
43+ ).decode ("utf-8" )
3744
3845
3946if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments