@@ -61,7 +61,7 @@ def get_xml_type(val):
61
61
return "null"
62
62
if isinstance (val , dict ):
63
63
return "dict"
64
- if isinstance (val , collections .Iterable ):
64
+ if isinstance (val , collections .abc . Iterable ):
65
65
return "list"
66
66
return type (val ).__name__
67
67
@@ -159,7 +159,7 @@ def convert(obj, ids, attr_type, item_func, cdata, item_wrap, parent="root"):
159
159
if isinstance (obj , dict ):
160
160
return convert_dict (obj , ids , parent , attr_type , item_func , cdata , item_wrap )
161
161
162
- if isinstance (obj , collections .Iterable ):
162
+ if isinstance (obj , collections .abc . Iterable ):
163
163
return convert_list (obj , ids , parent , attr_type , item_func , cdata , item_wrap )
164
164
165
165
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):
206
206
)
207
207
)
208
208
209
- elif isinstance (val , collections .Iterable ):
209
+ elif isinstance (val , collections .abc . Iterable ):
210
210
if attr_type :
211
211
attr ["type" ] = get_xml_type (val )
212
212
addline (
@@ -258,48 +258,82 @@ def convert_list(items, ids, parent, attr_type, item_func, cdata, item_wrap):
258
258
259
259
elif isinstance (item , dict ):
260
260
if not attr_type :
261
- if ( item_wrap ) :
261
+ if item_wrap :
262
262
addline (
263
263
"<%s>%s</%s>"
264
264
% (
265
265
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
+ ),
267
275
item_name ,
268
276
)
269
277
)
270
278
else :
271
279
addline (
272
280
"%s"
273
281
% (
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
+ ),
275
291
)
276
292
)
277
293
else :
278
- if ( item_wrap ) :
294
+ if item_wrap :
279
295
addline (
280
296
'<%s type="dict">%s</%s>'
281
297
% (
282
298
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
+ ),
284
308
item_name ,
285
309
)
286
310
)
287
311
else :
288
312
addline (
289
- '%s'
313
+ "%s"
290
314
% (
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
+ ),
292
324
)
293
325
)
294
326
295
- elif isinstance (item , collections .Iterable ):
327
+ elif isinstance (item , collections .abc . Iterable ):
296
328
if not attr_type :
297
329
addline (
298
330
"<%s %s>%s</%s>"
299
331
% (
300
332
item_name ,
301
333
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
+ ),
303
337
item_name ,
304
338
)
305
339
)
@@ -309,7 +343,9 @@ def convert_list(items, ids, parent, attr_type, item_func, cdata, item_wrap):
309
343
% (
310
344
item_name ,
311
345
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
+ ),
313
349
item_name ,
314
350
)
315
351
)
0 commit comments