On 04/01/2017, 17.43, "Mariano Lopez" <[email protected]> wrote: > >On 28/12/16 07:02, Markus Lehtonen wrote: >> -def dict_to_XML(tag, dictionary): >> +def dict_to_XML(tag, dictionary, **kwargs): >> """ Return XML element converting dicts recursively. """ >> >> - elem = Element(tag) >> + elem = Element(tag, **kwargs) >> for key, val in dictionary.items(): >> - if isinstance(val, MutableMapping): >> + if tag == 'layers': >> + child = (dict_to_XML('layer', val, name=key)) >> + elif isinstance(val, MutableMapping): >> child = (dict_to_XML(key, val)) >> else: >> child = Element(key) > >I was thinking that this function would be more generic, adding a >comparison to a tag name surely won't keep the function generic, is >there another way to implement this keeping this function generic enough?
I don't think it's possible to make a nice generic json to xml converter. The formats are just so different. I think the current method just generates bad xml. In the future, it would probably be better to just get rid of the json-to-xml conversion completely and make metadata_from_bb() to directly return an ElementTree. Thanks, Markus -- _______________________________________________ Openembedded-core mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-core
