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