From: Tony Mack Date: Wed, 26 Oct 2011 17:35:36 +0000 (-0400) Subject: parse_dict now supports ints and Non values X-Git-Tag: sfa-1.1-1~29 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=20b278aea6522b7bbf677a57a4631ad31bcb56ae parse_dict now supports ints and Non values --- diff --git a/sfa/util/xml.py b/sfa/util/xml.py index a1a6fa34..ce76b83a 100755 --- a/sfa/util/xml.py +++ b/sfa/util/xml.py @@ -75,7 +75,8 @@ class XML: def parse_dict(self, d, root_tag_name='xml', element = None): if element is None: - self.parse_xml('<%s/>' % root_tag_name) + if self.root is None: + self.parse_xml('<%s/>' % root_tag_name) element = self.root if 'text' in d: @@ -89,8 +90,12 @@ class XML: for val in value: if isinstance(val, dict): child_element = etree.SubElement(element, key) - self.parse_dict(val, key, child_element) - + self.parse_dict(val, key, child_element) + elif isinstance(value, int): + d[key] = unicode(d[key]) + elif value is None: + d.pop(key) + element.attrib.update(d) def validate(self, schema):