@@ -46,6 +46,15 @@ def UpdateMetaData(TemplateRoot, PartitionRoot):
4646 PartitionsSet .add ((label , filename ))
4747 print (f"PartitionsSet: { PartitionsSet } " )
4848
49+ def _add_file_elements (parent_element , file_name_text , file_path_flavor = None ):
50+ """Helper function to add file_name and file_path sub-elements."""
51+ new_file_name = ET .SubElement (parent_element , "file_name" )
52+ new_file_name .text = file_name_text
53+ new_file_path = ET .SubElement (parent_element , "file_path" )
54+ if file_path_flavor :
55+ new_file_path .set ("flavor" , file_path_flavor )
56+ new_file_path .text = "."
57+
4958 builds = TemplateRoot .findall ('builds_flat/build' )
5059 for build in builds :
5160 Name = build .find ('name' )
@@ -59,24 +68,15 @@ def UpdateMetaData(TemplateRoot, PartitionRoot):
5968 for Partition in PartitionsSet :
6069 new_download_file = ET .SubElement (build , "download_file" )
6170 new_download_file .set ("fastboot_complete" , Partition [0 ])
62- new_file_name = ET .SubElement (new_download_file , "file_name" )
63- new_file_name .text = Partition [1 ]
64- new_file_path = ET .SubElement (new_download_file , "file_path" )
65- new_file_path .text = "."
71+ _add_file_elements (new_download_file , Partition [1 ])
6672 # GPT Main & GPT Backup entries
6773 for PhysicalPartitionNumber in range (0 , len (PhyPartition )):
6874 new_download_file = ET .SubElement (build , "download_file" )
6975 new_download_file .set ("storage_type" , DefaultStorageType )
70- new_file_name = ET .SubElement (new_download_file , "file_name" )
71- new_file_name .text = 'gpt_main%d.xml' % (PhysicalPartitionNumber )
72- new_file_path = ET .SubElement (new_download_file , "file_path" )
73- new_file_path .text = "."
76+ _add_file_elements (new_download_file , 'gpt_main%d.xml' % (PhysicalPartitionNumber ))
7477 new_download_file = ET .SubElement (build , "download_file" )
7578 new_download_file .set ("storage_type" , DefaultStorageType )
76- new_file_name = ET .SubElement (new_download_file , "file_name" )
77- new_file_name .text = 'gpt_backup%d.xml' % (PhysicalPartitionNumber )
78- new_file_path = ET .SubElement (new_download_file , "file_path" )
79- new_file_path .text = "."
79+ _add_file_elements (new_download_file , 'gpt_backup%d.xml' % (PhysicalPartitionNumber ))
8080
8181 PartitionFile = build .find ('partition_file' )
8282 if PartitionFile is not None :
@@ -85,11 +85,7 @@ def UpdateMetaData(TemplateRoot, PartitionRoot):
8585 for PhysicalPartitionNumber in range (0 , len (PhyPartition )):
8686 new_partition_file = ET .SubElement (build , "partition_file" )
8787 new_partition_file .set ("storage_type" , DefaultStorageType )
88- new_file_name = ET .SubElement (new_partition_file , "file_name" )
89- new_file_name .text = 'rawprogram%d.xml' % (PhysicalPartitionNumber )
90- new_file_path = ET .SubElement (new_partition_file , "file_path" )
91- new_file_path .set ("flavor" , "default" )
92- new_file_path .text = "."
88+ _add_file_elements (new_partition_file , 'rawprogram%d.xml' % (PhysicalPartitionNumber ), "default" )
9389
9490 PartitionPatchFile = build .find ('partition_patch_file' )
9591 if PartitionPatchFile is not None :
@@ -98,11 +94,7 @@ def UpdateMetaData(TemplateRoot, PartitionRoot):
9894 for PhysicalPartitionNumber in range (0 , len (PhyPartition )):
9995 new_partition_patch_file = ET .SubElement (build , "partition_patch_file" )
10096 new_partition_patch_file .set ("storage_type" , DefaultStorageType )
101- new_file_name = ET .SubElement (new_partition_patch_file , "file_name" )
102- new_file_name .text = 'patch%d.xml' % (PhysicalPartitionNumber )
103- new_file_path = ET .SubElement (new_partition_patch_file , "file_path" )
104- new_file_path .set ("flavor" , "default" )
105- new_file_path .text = "."
97+ _add_file_elements (new_partition_patch_file , 'patch%d.xml' % (PhysicalPartitionNumber ), "default" )
10698
10799###############################################################################
108100# main
0 commit comments