File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,9 @@ def dict2xml(root):
192192 >>> print(dict2xml(attrdict))
193193 <attributeAssertion FriendlyName="DeveloperID" Name="DevId" NameFormat="String"><urn:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">mydevid</urn:AttributeValue></attributeAssertion><attributeAssertion FriendlyName="ApplicationID" Name="AppId" NameFormat="String"><urn:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">myappid</urn:AttributeValue></attributeAssertion><attributeAssertion FriendlyName="Certificate" Name="CertId" NameFormat="String"><urn:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">mycertid</urn:AttributeValue></attributeAssertion>
194194
195+ >>> dict2xml("łśżźć")
196+ '\\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87'
197+
195198 >>> dict_special = {
196199 ... 'searchFilter': {'categoryId': {'#text': 'SomeID - łśżźć', '@attrs': {'site': 'US - łśżźć'} }},
197200 ... 'paginationInput': {
@@ -206,7 +209,7 @@ def dict2xml(root):
206209 ... ],
207210 ... 'sortOrder': 'StartTimeNewest - łśżźć'
208211 ... }
209- >>> dict2xml(dict_special) # doctest: +SKIP
212+ >>> dict2xml(dict_special)
210213 '<itemFilter><name>Condition - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</name><value>Used - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</value></itemFilter><itemFilter><name>LocatedIn - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</name><value>GB - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</value></itemFilter><paginationInput><pageNumber>1 - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</pageNumber><pageSize>25 - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</pageSize></paginationInput><searchFilter><categoryId site="US - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87">SomeID - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</categoryId></searchFilter><sortOrder>StartTimeNewest - \\ xc5\\ x82\\ xc5\\ x9b\\ xc5\\ xbc\\ xc5\\ xba\\ xc4\\ x87</sortOrder>'
211214 '''
212215
@@ -259,7 +262,7 @@ def dict2xml(root):
259262 elif isinstance (root , str ) or isinstance (root , int ) \
260263 or isinstance (root , unicode ) or isinstance (root , long ) \
261264 or isinstance (root , float ):
262- xml = str ('{0}{1}' ).format (str (xml ), root )
265+ xml = str ('{0}{1}' ).format (str (xml ), smart_encode ( root ) )
263266 else :
264267 raise Exception ('Unable to serialize node of type %s (%s)' % \
265268 (type (root ), root ))
You can’t perform that action at this time.
0 commit comments