Update xmltodict library 0.9.0 to 0.9.2 (579a005).

This commit is contained in:
JackDandy 2015-06-14 00:01:04 +01:00
parent 78c2ed237c
commit 6bab75036f
2 changed files with 16 additions and 9 deletions

View file

@ -41,6 +41,7 @@
* Change check_url function to use requests instead of httplib library * Change check_url function to use requests instead of httplib library
* Update Six compatibility library 1.5.2 to 1.9.0 (8a545f4) * Update Six compatibility library 1.5.2 to 1.9.0 (8a545f4)
* Update SimpleJSON library 2.0.9 to 3.7.3 (0bcdf20) * Update SimpleJSON library 2.0.9 to 3.7.3 (0bcdf20)
* Update xmltodict library 0.9.0 to 0.9.2 (579a005)
[develop changelog] [develop changelog]
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457) * Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)

View file

@ -29,7 +29,7 @@ except NameError: # pragma no cover
_unicode = str _unicode = str
__author__ = 'Martin Blech' __author__ = 'Martin Blech'
__version__ = '0.9.0' __version__ = '0.9.2'
__license__ = 'MIT' __license__ = 'MIT'
@ -94,7 +94,7 @@ class _DictSAXHandler(object):
self.stack.append((self.item, self.data)) self.stack.append((self.item, self.data))
if self.xml_attribs: if self.xml_attribs:
attrs = self.dict_constructor( attrs = self.dict_constructor(
(self.attr_prefix+key, value) (self.attr_prefix+self._build_name(key), value)
for (key, value) in attrs.items()) for (key, value) in attrs.items())
else: else:
attrs = None attrs = None
@ -256,17 +256,20 @@ def _emit(key, value, content_handler,
preprocessor=None, preprocessor=None,
pretty=False, pretty=False,
newl='\n', newl='\n',
indent='\t'): indent='\t',
full_document=True):
if preprocessor is not None: if preprocessor is not None:
result = preprocessor(key, value) result = preprocessor(key, value)
if result is None: if result is None:
return return
key, value = result key, value = result
if not isinstance(value, (list, tuple)): if (not hasattr(value, '__iter__')
or isinstance(value, _basestring)
or isinstance(value, dict)):
value = [value] value = [value]
if depth == 0 and len(value) > 1: for index, v in enumerate(value):
raise ValueError('document with multiple roots') if full_document and depth == 0 and index > 0:
for v in value: raise ValueError('document with multiple roots')
if v is None: if v is None:
v = OrderedDict() v = OrderedDict()
elif not isinstance(v, dict): elif not isinstance(v, dict):
@ -318,7 +321,8 @@ def unparse(input_dict, output=None, encoding='utf-8', full_document=True,
can be customized with the `newl` and `indent` parameters. can be customized with the `newl` and `indent` parameters.
""" """
((key, value),) = input_dict.items() if full_document and len(input_dict) != 1:
raise ValueError('Document must have exactly one root.')
must_return = False must_return = False
if output is None: if output is None:
output = StringIO() output = StringIO()
@ -326,7 +330,9 @@ def unparse(input_dict, output=None, encoding='utf-8', full_document=True,
content_handler = XMLGenerator(output, encoding) content_handler = XMLGenerator(output, encoding)
if full_document: if full_document:
content_handler.startDocument() content_handler.startDocument()
_emit(key, value, content_handler, **kwargs) for key, value in input_dict.items():
_emit(key, value, content_handler, full_document=full_document,
**kwargs)
if full_document: if full_document:
content_handler.endDocument() content_handler.endDocument()
if must_return: if must_return: