def insert_urls(uploads_url_prefix, eml_node, node_type):
    upload_nodes = []
    eml_node.find_all_descendants(node_type, upload_nodes)
    for upload_node in upload_nodes:
        try:
            physical_node = upload_node.find_descendant(names.PHYSICAL)
            object_name_node = physical_node.find_child(names.OBJECTNAME)
            object_name = object_name_node.content
            distribution_node = physical_node.find_child(names.DISTRIBUTION)
            if distribution_node:
                physical_node.remove_child(distribution_node)
            distribution_node = new_child_node(names.DISTRIBUTION, physical_node)
            online_node = new_child_node(names.ONLINE, distribution_node)
            url_node = new_child_node(names.URL, online_node)
            url_node.add_attribute('function', 'download')
            url_node.content = f'{uploads_url_prefix}/{object_name}'.replace(' ', '%20')
        except Exception as err:
            flash(err)
            continue
def insert_urls(uploads_url_prefix, eml_node, node_type):
    upload_nodes = []
    eml_node.find_all_descendants(node_type, upload_nodes)
    for upload_node in upload_nodes:
        try:
            physical_node = upload_node.find_descendant(names.PHYSICAL)
            object_name_node = physical_node.find_child(names.OBJECTNAME)
            object_name = object_name_node.content
            distribution_node = physical_node.find_child(names.DISTRIBUTION)
            if distribution_node:
                physical_node.remove_child(distribution_node)
            distribution_node = new_child_node(names.DISTRIBUTION, physical_node)
            online_node = new_child_node(names.ONLINE, distribution_node)
            url_node = new_child_node(names.URL, online_node)
            url_node.add_attribute('function', 'download')
            url_node.content = f'{uploads_url_prefix}/{object_name}'.replace(' ', '%20')
        except Exception as err:
            flash(err)
            continue