intel/genxml: Migrate from deprecated xml.etree.ElementTree getchildren.
authorVinson Lee <vlee@freedesktop.org>
Fri, 5 Jun 2020 07:36:55 +0000 (00:36 -0700)
committerMarge Bot <eric+marge@anholt.net>
Sat, 6 Jun 2020 08:20:13 +0000 (08:20 +0000)
xml.etree.ElementTree getchildren was deprecated since Python 2.7 and
will be removed in Python 3.9.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5348>

src/intel/genxml/gen_sort_tags.py

index f87bb2bfe6ef56ca3ee77a14c8e4ed21768bff4e..10fe8d4b178bcfc83def2896e541a3d3323ef6e3 100755 (executable)
@@ -66,7 +66,7 @@ def add_struct_refs(items, node):
         return
     if node.tag != 'struct' and node.tag != 'group':
         return
-    for c in node.getchildren():
+    for c in node:
         add_struct_refs(items, c)
 
 
@@ -116,7 +116,7 @@ def print_node(f, offset, node):
     for a in attribs:
         if a in node.attrib:
             f.write(' {0}="{1}"'.format(a, node.attrib[a]))
-    children = node.getchildren()
+    children = list(node)
     if len(children) > 0:
         f.write('>\n')
         for c in children:
@@ -134,7 +134,7 @@ def process(filename):
     enum_dict = {}
     for e in enums:
         values = e.findall('./value')
-        e[:] = sorted(e.getchildren(), key=get_value)
+        e[:] = sorted(e, key=get_value)
         enum_dict[e.attrib['name']] = e
 
     # Structs are a bit annoying because they can refer to each other. We sort
@@ -143,7 +143,7 @@ def process(filename):
     structs = sorted(xml.findall('./struct'), key=get_name)
     wrapped_struct_dict = {}
     for s in structs:
-        s[:] = sorted(s.getchildren(), key=get_start)
+        s[:] = sorted(s, key=get_start)
         ws = Struct(s)
         wrapped_struct_dict[ws.name] = ws
 
@@ -157,11 +157,11 @@ def process(filename):
 
     instructions = sorted(xml.findall('./instruction'), key=get_name)
     for i in instructions:
-        i[:] = sorted(i.getchildren(), key=get_start)
+        i[:] = sorted(i, key=get_start)
 
     registers = sorted(xml.findall('./register'), key=get_name)
     for r in registers:
-        r[:] = sorted(r.getchildren(), key=get_start)
+        r[:] = sorted(r, key=get_start)
 
     genxml[:] = enums + list(sorted_structs.values()) + instructions + registers