(self, nodes, current_dir, parent_xml_node, staging_dir)
Create XML file
Create XML file
Create XML file
def create_xml(self, nodes, current_dir, parent_xml_node, staging_dir):
        '''
           Create XML file
        '''
        cur_node = nodes[current_dir]
        if cur_node.files:
            component_id = f'ApplicationFiles{self.component_num}'
            comp_xml_node = ET.SubElement(parent_xml_node, 'Component', {
                'Id': component_id,
                'Guid': gen_guid(),
            })
            self.feature_components[staging_dir].append(component_id)
            comp_xml_node.set('Win64', 'yes')
            if self.component_num == 0:
                ET.SubElement(comp_xml_node, 'Environment', {
                    'Id': 'Environment',
                    'Name': 'PATH',
                    'Part': 'last',
                    'System': 'yes',
                    'Action': 'set',
                    'Value': '[INSTALLDIR]',
                })
            self.component_num += 1
            for f_node in cur_node.files:
                file_id = os.path.join(current_dir, f_node).replace('\\', '_').replace('#', '_').replace('-', '_')
                ET.SubElement(comp_xml_node, 'File', {
                    'Id': file_id,
                    'Name': f_node,
                    'Source': os.path.join(current_dir, f_node),
                })

        for dirname in cur_node.dirs:
            dir_id = os.path.join(current_dir, dirname).replace('\\', '_').replace('/', '_')
            dir_node = ET.SubElement(parent_xml_node, 'Directory', {
                'Id': dir_id,
                'Name': dirname,
            })
            self.create_xml(nodes, os.path.join(current_dir, dirname), dir_node, staging_dir)
def create_xml ( self , nodes , current_dir , parent_xml_node , staging_dir ) : cur_node = nodes [ current_dir ] if cur_node . files : component_id = f'ApplicationFiles{self.component_num}' comp_xml_node = ET . SubElement ( parent_xml_node , 'Component' , { 'Id' : component_id , 'Guid' : gen_guid ( ) , } ) self . feature_components [ staging_dir ] . append ( component_id ) comp_xml_node . set ( 'Win64' , 'yes' ) if self . component_num == 0 : ET . SubElement ( comp_xml_node , 'Environment' , { 'Id' : 'Environment' , 'Name' : 'PATH' , 'Part' : 'last' , 'System' : 'yes' , 'Action' : 'set' , 'Value' : '[INSTALLDIR]' , } ) self . component_num += 1 for f_node in cur_node . files : file_id = os . path . join ( current_dir , f_node ) . replace ( '\\' , '_' ) . replace ( '#' , '_' ) . replace ( '-' , '_' ) ET . SubElement ( comp_xml_node , 'File' , { 'Id' : file_id , 'Name' : f_node , 'Source' : os . path . join ( current_dir , f_node ) , } ) for dirname in cur_node . dirs : dir_id = os . path . join ( current_dir , dirname ) . replace ( '\\' , '_' ) . replace ( '/' , '_' ) dir_node = ET . SubElement ( parent_xml_node , 'Directory' , { 'Id' : dir_id , 'Name' : dirname , } ) self . create_xml ( nodes , os . path . join ( current_dir , dirname ) , dir_node , staging_dir )