Пример #1
0
def save_to_xml(proj, filename):
    import codecs
    
    data = u""
    data += utils.xml_create_header()   

    data += utils.xml_create_start_tag(0, "Project")
    data += utils.xml_create_property(1, "Name", proj.name)

    data += utils.xml_create_start_tag(1, "Scripts")
    for script in proj.get_pool_list_absolute():
        data += _create_script(2, script.get_name(), XML_PATH_SEP.join(script.get_path()))
    data += utils.xml_create_stop_tag(1, "Scripts")    
    
    for campaign in proj.campaigns :
        data += utils.xml_create_start_tag(1, "Campaign")        
        data += utils.xml_create_property(2, "Name", campaign.name)
        for script in proj.get_campaign_list_scripts(campaign.name):
            data += _create_script(2, script.get_name(), XML_PATH_SEP.join(script.get_path()))
        data += utils.xml_create_stop_tag(1, "Campaign") 
        
    data += utils.xml_create_stop_tag(0, "Project")

    file = codecs.open(filename, "w", "utf-8")
    file.write(data)
    file.close()
Пример #2
0
def save_to_xml(proj, filename):
    import codecs

    data = u""
    data += utils.xml_create_header()

    data += utils.xml_create_start_tag(0, "Project")
    data += utils.xml_create_property(1, "Name", proj.name)

    data += utils.xml_create_start_tag(1, "Scripts")
    for script in proj.get_pool_list_absolute():
        data += _create_script(2, script.get_name(),
                               XML_PATH_SEP.join(script.get_path()))
    data += utils.xml_create_stop_tag(1, "Scripts")

    for campaign in proj.campaigns:
        data += utils.xml_create_start_tag(1, "Campaign")
        data += utils.xml_create_property(2, "Name", campaign.name)
        for script in proj.get_campaign_list_scripts(campaign.name):
            data += _create_script(2, script.get_name(),
                                   XML_PATH_SEP.join(script.get_path()))
        data += utils.xml_create_stop_tag(1, "Campaign")

    data += utils.xml_create_stop_tag(0, "Project")

    file = codecs.open(filename, "w", "utf-8")
    file.write(data)
    file.close()
Пример #3
0
def _create_script(level, name, path):
    data = u""
    data += utils.xml_create_start_tag(level, "Script")
    data += utils.xml_create_property(level+1, "Name", name)
    data += utils.xml_create_property(level+1, "Path", path)
    data += utils.xml_create_stop_tag(level, "Script")    
    return data    
Пример #4
0
def _create_script(level, name, path):
    data = u""
    data += utils.xml_create_start_tag(level, "Script")
    data += utils.xml_create_property(level + 1, "Name", name)
    data += utils.xml_create_property(level + 1, "Path", path)
    data += utils.xml_create_stop_tag(level, "Script")
    return data