本文整理汇总了Python中constants.Constants.indent方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.indent方法的具体用法?Python Constants.indent怎么用?Python Constants.indent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类constants.Constants
的用法示例。
在下文中一共展示了Constants.indent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_xml
# 需要导入模块: from constants import Constants [as 别名]
# 或者: from constants.Constants import indent [as 别名]
def to_xml(self, xml_name):
print "generating plan to %s" % xml_name
root = ElementTree.Element('testplan')
for suite_name in self.suites:
suite = self.suites[suite_name]
root.append(suite.to_xml())
Constants.indent(root)
tree = ElementTree.ElementTree()
tree._setroot(root)
tree.write(xml_name, encoding="utf-8")
示例2: merge_suite_result
# 需要导入模块: from constants import Constants [as 别名]
# 或者: from constants.Constants import indent [as 别名]
def merge_suite_result(self, result_xml, plan_name):
os.chdir(self.latest_result_folder)
root = ElementTree.Element('test_definition')
first = True
start_at = None
end_at = None
summary_xml = TotalSummary(plan_name)
for suite_name in self.suites:
result_name = "%s.xml" % suite_name
if os.path.isfile(result_name):
print "Reading the result of suite : %s" % suite_name
if True:
xml_tree = ElementTree.parse(result_name)
xml_root = xml_tree.getroot()
if first:
first = False
env_elm = xml_root.find('environment')
root.append(env_elm)
summary_xml.set_environment(env_elm)
root.append(xml_root.find('summary'))
summary = xml_root.find('summary')
this_start = summary.find('start_at')
this_end = summary.find('end_at')
start_at = self.select_start_at(start_at, this_start.text)
end_at = self.select_end_at(end_at, this_end.text)
for this_suite in xml_root.findall('suite'):
root.append(this_suite)
summary_xml.add_suite_elm(this_suite)
else:
print "[Error] the expecting result of the suite %s is not found! " % suite_name
s_tag = root.find('summary/start_at')
if s_tag is not None:
s_tag.text = start_at
e_tag = root.find('summary/end_at')
if e_tag is not None:
e_tag.text = end_at
sum_elm = root.find('summary')
summary_xml.set_summary(sum_elm)
capability_root = self.parse_capablities()
summary_xml.set_capabilities(capability_root)
tree = ElementTree.ElementTree()
tree._setroot(root)
d = os.path.abspath(os.path.dirname(result_xml))
if not os.path.exists(d):
os.makedirs(d)
tree.write(result_xml, encoding="utf-8")
print "Generating the merged result XML '%s'" % result_xml
sum_tree = ElementTree.ElementTree()
sum_root = summary_xml.to_xml()
Constants.indent(sum_root)
sum_tree._setroot(sum_root)
print "Generating the summary XML in %s" % (self.latest_result_folder + "summary.xml")
outFile = open(self.latest_result_folder + "summary.xml", 'w')
outFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
outFile.write("<?xml-stylesheet type=\"text/xsl\" href=\"summary.xsl\"?>\n")
sum_tree.write(outFile, encoding="utf-8")
outFile.close()