Skip to content

Commit 21e6ec2

Browse files
committed
vtr_flow: skip xml conversion if tiles tag exists
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 609c8c9 commit 21e6ec2

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

vtr_flow/scripts/add_tiles.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,28 @@ def main():
7272
arch_xml = ET.ElementTree()
7373
root_element = arch_xml.parse(args.arch_xml)
7474

75-
tiles = ET.SubElement(root_element, 'tiles')
75+
tiles = arch_xml.find('tiles')
7676

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')
8179

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)
8584

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
8888

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))
9291

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)
9497

9598
print(ET.tostring(arch_xml, pretty_print=True).decode('utf-8'))
9699

0 commit comments

Comments
 (0)