@@ -61,7 +61,7 @@ def get_xml_type(val):
6161 return "null"
6262 if isinstance (val , dict ):
6363 return "dict"
64- if isinstance (val , collections .Iterable ):
64+ if isinstance (val , collections .abc . Iterable ):
6565 return "list"
6666 return type (val ).__name__
6767
@@ -159,7 +159,7 @@ def convert(obj, ids, attr_type, item_func, cdata, item_wrap, parent="root"):
159159 if isinstance (obj , dict ):
160160 return convert_dict (obj , ids , parent , attr_type , item_func , cdata , item_wrap )
161161
162- if isinstance (obj , collections .Iterable ):
162+ if isinstance (obj , collections .abc . Iterable ):
163163 return convert_list (obj , ids , parent , attr_type , item_func , cdata , item_wrap )
164164
165165 raise TypeError ("Unsupported data type: %s (%s)" % (obj , type (obj ).__name__ ))
@@ -206,7 +206,7 @@ def convert_dict(obj, ids, parent, attr_type, item_func, cdata, item_wrap):
206206 )
207207 )
208208
209- elif isinstance (val , collections .Iterable ):
209+ elif isinstance (val , collections .abc . Iterable ):
210210 if attr_type :
211211 attr ["type" ] = get_xml_type (val )
212212 addline (
@@ -258,48 +258,82 @@ def convert_list(items, ids, parent, attr_type, item_func, cdata, item_wrap):
258258
259259 elif isinstance (item , dict ):
260260 if not attr_type :
261- if ( item_wrap ) :
261+ if item_wrap :
262262 addline (
263263 "<%s>%s</%s>"
264264 % (
265265 item_name ,
266- convert_dict (item , ids , parent , attr_type , item_func , cdata , item_wrap ),
266+ convert_dict (
267+ item ,
268+ ids ,
269+ parent ,
270+ attr_type ,
271+ item_func ,
272+ cdata ,
273+ item_wrap ,
274+ ),
267275 item_name ,
268276 )
269277 )
270278 else :
271279 addline (
272280 "%s"
273281 % (
274- convert_dict (item , ids , parent , attr_type , item_func , cdata , item_wrap ),
282+ convert_dict (
283+ item ,
284+ ids ,
285+ parent ,
286+ attr_type ,
287+ item_func ,
288+ cdata ,
289+ item_wrap ,
290+ ),
275291 )
276292 )
277293 else :
278- if ( item_wrap ) :
294+ if item_wrap :
279295 addline (
280296 '<%s type="dict">%s</%s>'
281297 % (
282298 item_name ,
283- convert_dict (item , ids , parent , attr_type , item_func , cdata , item_wrap ),
299+ convert_dict (
300+ item ,
301+ ids ,
302+ parent ,
303+ attr_type ,
304+ item_func ,
305+ cdata ,
306+ item_wrap ,
307+ ),
284308 item_name ,
285309 )
286310 )
287311 else :
288312 addline (
289- '%s'
313+ "%s"
290314 % (
291- convert_dict (item , ids , parent , attr_type , item_func , cdata , item_wrap ),
315+ convert_dict (
316+ item ,
317+ ids ,
318+ parent ,
319+ attr_type ,
320+ item_func ,
321+ cdata ,
322+ item_wrap ,
323+ ),
292324 )
293325 )
294326
295- elif isinstance (item , collections .Iterable ):
327+ elif isinstance (item , collections .abc . Iterable ):
296328 if not attr_type :
297329 addline (
298330 "<%s %s>%s</%s>"
299331 % (
300332 item_name ,
301333 make_attrstring (attr ),
302- convert_list (item , ids , item_name , attr_type , item_func , cdata , item_wrap ),
334+ convert_list (
335+ item , ids , item_name , attr_type , item_func , cdata , item_wrap
336+ ),
303337 item_name ,
304338 )
305339 )
@@ -309,7 +343,9 @@ def convert_list(items, ids, parent, attr_type, item_func, cdata, item_wrap):
309343 % (
310344 item_name ,
311345 make_attrstring (attr ),
312- convert_list (item , ids , item_name , attr_type , item_func , cdata , item_wrap ),
346+ convert_list (
347+ item , ids , item_name , attr_type , item_func , cdata , item_wrap
348+ ),
313349 item_name ,
314350 )
315351 )
0 commit comments