]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa.utils.metadata: have layer name as an attribute in xml
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 13 Jan 2017 13:12:43 +0000 (15:12 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 19 Jan 2017 22:45:46 +0000 (22:45 +0000)
Have the layer name as an attribute instead of of the name of the
element itself. That is, have <layer name="layer_name"/> instead of
<layer_name/>. A bit better XML design.

[YOCTO #10590]

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/lib/oeqa/utils/metadata.py

index d5cc2906b1a6cf18f4d8c24a235df95f16cf0ee5..6331c21f6d71e96aecf0172bb0fb02937eb5a307 100644 (file)
@@ -90,12 +90,14 @@ def write_metadata_file(file_path, metadata):
     with open(file_path, 'w') as f:
         f.write(xml_doc.toprettyxml())
 
-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)