@@ -72,25 +72,28 @@ def main():
72
72
arch_xml = ET .ElementTree ()
73
73
root_element = arch_xml .parse (args .arch_xml )
74
74
75
- tiles = ET . SubElement ( root_element , 'tiles' )
75
+ tiles = arch_xml . find ( 'tiles' )
76
76
77
- top_pb_types = []
78
- for pb_type in root_element .iter ('pb_type' ):
79
- if pb_type .getparent ().tag == 'complexblocklist' :
80
- top_pb_types .append (pb_type )
77
+ if tiles is None :
78
+ tiles = ET .SubElement (root_element , 'tiles' )
81
79
82
- for pb_type in top_pb_types :
83
- tile = ET .SubElement (tiles , 'tile' )
84
- attrs = pb_type .attrib
80
+ top_pb_types = []
81
+ for pb_type in root_element .iter ('pb_type' ):
82
+ if pb_type .getparent ().tag == 'complexblocklist' :
83
+ top_pb_types .append (pb_type )
85
84
86
- for attr in attrs :
87
- tile .set (attr , pb_type .get (attr ))
85
+ for pb_type in top_pb_types :
86
+ tile = ET .SubElement (tiles , 'tile' )
87
+ attrs = pb_type .attrib
88
88
89
- # Remove attributes of top level pb_types only
90
- for attr in ATTR_TO_REMOVE :
91
- pb_type .attrib .pop (attr , None )
89
+ for attr in attrs :
90
+ tile .set (attr , pb_type .get (attr ))
92
91
93
- swap_tags (tile , pb_type )
92
+ # Remove attributes of top level pb_types only
93
+ for attr in ATTR_TO_REMOVE :
94
+ pb_type .attrib .pop (attr , None )
95
+
96
+ swap_tags (tile , pb_type )
94
97
95
98
print (ET .tostring (arch_xml , pretty_print = True ).decode ('utf-8' ))
96
99
0 commit comments