本文整理汇总了Python中comoonics.XmlTools.evaluateXPath方法的典型用法代码示例。如果您正苦于以下问题:Python XmlTools.evaluateXPath方法的具体用法?Python XmlTools.evaluateXPath怎么用?Python XmlTools.evaluateXPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comoonics.XmlTools
的用法示例。
在下文中一共展示了XmlTools.evaluateXPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_evaluateXPath
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import evaluateXPath [as 别名]
def test_evaluateXPath(self):
for doc in self.docs:
if len(doc) > 1:
(doc, xpathtest)=doc
(xpath, expectedresult, dummy) = xpathtest
result=XmlTools.evaluateXPath(xpath, doc)
self.assertEquals(result, expectedresult, "Result of xpath %s in document does not equals the expected result: %s != %s" %(xpath, result, expectedresult))
示例2: hasFlag
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import evaluateXPath [as 别名]
def hasFlag(self, name):
try:
from comoonics import XmlTools
return len(XmlTools.evaluateXPath("flag/@name=" + name, self.element))
except Exception:
return False
示例3: removeFlag
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import evaluateXPath [as 别名]
def removeFlag(self, name):
try:
from comoonics import XmlTools
node=XmlTools.evaluateXPath('flag/@name='+name, self.element)[0]
self.element.removeChild(node)
except Exception:
raise ComException("no flag with name %s found" %name)
示例4: getClusterName
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import evaluateXPath [as 别名]
def getClusterName(self):
"""
FIXME (marc): Should go in some cluster api (ccs_xml_query!!)
Cluster->getClusterName()
|
-> RedhatCluster->getClusterName()
"""
from comoonics import XmlTools
return XmlTools.evaluateXPath(self.XPATH_CLUSTERNAME, self.cluster_conf)[0].nodeValue
示例5: getClusterName
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import evaluateXPath [as 别名]
def getClusterName(self):
"""
FIXME (marc): Should go in some cluster api (ccs_xml_query!!)
Cluster->getClusterName()
|
-> RedhatCluster->getClusterName()
"""
from comoonics import XmlTools
if self.type==SystemTypes.CLUSTER:
return XmlTools.evaluateXPath(self.XPATH_CLUSTERNAME, self.cluster_conf)[0]
else:
return "unknown"
示例6: getXPathFromXMLFile
# 需要导入模块: from comoonics import XmlTools [as 别名]
# 或者: from comoonics.XmlTools import evaluateXPath [as 别名]
def getXPathFromXMLFile(xpath, filename):
try:
from comoonics import XmlTools
document=XmlTools.parseXMLFile(filename)
return XmlTools.evaluateXPath(xpath, document.documentElement)
except ImportError:
import xml.dom.minidom
from xml.xpath import Evaluate
import os
filep = os.fdopen(os.open(filename, os.O_RDONLY))
doc=xml.dom.minidom.parse(filep)
return Evaluate(xpath, doc.documentElement)