本文整理汇总了Python中comoonics.XmlTools.overwrite_attributes_with_xpaths方法的典型用法代码示例。如果您正苦于以下问题:Python XmlTools.overwrite_attributes_with_xpaths方法的具体用法?Python XmlTools.overwrite_attributes_with_xpaths怎么用?Python XmlTools.overwrite_attributes_with_xpaths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comoonics.XmlTools
的用法示例。
在下文中一共展示了XmlTools.overwrite_attributes_with_xpaths方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: overwriteDestination
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import overwrite_attributes_with_xpaths [as 别名]
def overwriteDestination(self):
from comoonics import XmlTools
self.enterprisecopy=EnterpriseCopy(XmlTools.overwrite_attributes_with_xpaths(self.enterprisecopy.getElement(), self.getOverwriteMap()), self.enterprisecopy.getDocument())
for setname in self.sets:
for myset in self.enterprisecopy.allsets:
if myset.hasAttribute("name") and myset.getAttribute("name"):
self.sets[setname]=myset
return self.enterprisecopy.getElement()
示例2: test_overwrite_attributes_with_xpaths
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import overwrite_attributes_with_xpaths [as 别名]
def test_overwrite_attributes_with_xpaths(self):
for doc in self.docs:
if len(doc) > 1:
(doc, xpathtest)=doc
(xpath, expectedresult, newvalue) = xpathtest
xml2=XmlTools.overwrite_attributes_with_xpaths(doc.documentElement, { xpath: newvalue })
buf=XmlTools.toPrettyXML(xml2)
self.assertEquals(buf.replace("\n", "").replace(" ", "").replace('<?xmlversion="1.0"?>', ""),
XmlTools.toPrettyXML(doc).replace("\n", "").replace(" ", "").replace('<?xmlversion="1.0"?>', "").replace("lilr629", "myname").replace("/dev/sda1", "mydisk"))
示例3: test_overwrite_attributes_with_xpaths2
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import overwrite_attributes_with_xpaths [as 别名]
def test_overwrite_attributes_with_xpaths2(self):
doc="""<a>
<b name="hallo"/>
<b name="hallo2"/>
<c name="hallo3"/>
<c name2="hallo4"/>
<c name="hallo5"/>
</a>
"""
edoc="""<a>
<b name="marc"/>
<b name="marc"/>
<c name="marc"/>
<c name2="hallo4"/>
<c name="marc"/>
</a>
"""
rdoc=XmlTools.overwrite_attributes_with_xpaths(XmlTools.parseXMLString(doc), {"//b/@name": "marc", "/a/c/@name": "marc"})
self.failUnlessEqual(XmlTools.toPrettyXML(rdoc).replace("\n", "").replace(" ", "").replace("\t", "").replace('<?xmlversion="1.0"?>', ""), edoc.replace("\n", "").replace(" ", "").replace("\t", ""))