[OE-core] [PATCH 7/8] oeqa.utils.metadata: have layer name as an attribute in xml

Markus Lehtonen markus.lehtonen at linux.intel.com
Thu Jan 5 09:35:54 UTC 2017


On 04/01/2017, 17.43, "Mariano Lopez" <mariano.lopez at linux.intel.com>
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





More information about the Openembedded-core mailing list