Conditions | 4 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.0218 |
1 | # -*- coding: utf-8 -*- |
||
23 | 10 | def dict_to_xml(d, sign): |
|
24 | 10 | xml = ['<xml>\n'] |
|
25 | 10 | for k in sorted(d): |
|
26 | # use sorted to avoid test error on Py3k |
||
27 | 10 | v = d[k] |
|
28 | 10 | if isinstance(v, six.integer_types) or v.isdigit(): |
|
29 | xml.append('<{0}>{1}</{0}>\n'.format(to_text(k), to_text(v))) |
||
30 | else: |
||
31 | 10 | xml.append( |
|
32 | '<{0}><![CDATA[{1}]]></{0}>\n'.format(to_text(k), to_text(v)) |
||
33 | ) |
||
34 | 10 | xml.append('<sign><![CDATA[{0}]]></sign>\n</xml>'.format(to_text(sign))) |
|
35 | 10 | return ''.join(xml) |
|
36 | |||
48 |