Esempio n. 1
0
 def _dict_to_etree(self, parent, d):
     for key, value in d.items():
         tag = re.sub('\W', '', snake_to_camel(key))
         # TODO: any other dict class?
         if isinstance(value, (dict, DictMixin)):
             elem = SubElement(parent, tag)
             self._dict_to_etree(elem, value)
         else:
             SubElement(parent, tag).text = value
Esempio n. 2
0
    def _dict_to_etree(self, parent, d):
        for key, value in d.items():
            tag = re.sub('\W', '', snake_to_camel(key))
            elem = SubElement(parent, tag)

            if isinstance(value, (dict, DictMixin)):
                self._dict_to_etree(elem, value)
            else:
                try:
                    elem.text = str(value)
                except ValueError:
                    # We set an invalid string for XML.
                    elem.text = '(invalid string)'
Esempio n. 3
0
 def test_snake_to_camel(self):
     for s1, s2 in strs:
         self.assertEquals(s1, utils.snake_to_camel(s2))