# HG changeset patch
# User Zhengang Li <lizg(a)cn.ibm.com>
# Date 1207733009 -28800
# Node ID 87913147308d5075130dcae5b5648cc3f0158681
# Parent 262153788503c8b10c76c77719bba081df9a7b88
[TEST] add a try..except to get_value_xpath()
A 'None' return is more elegant than a pure exception error.
Signed-off-by: Zhengang Li <lizg(a)cn.ibm.com>
diff -r 262153788503 -r 87913147308d suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Apr 08 17:58:44 2008 +0530
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 09 17:23:29 2008 +0800
@@ -115,7 +115,12 @@ class XMLClass:
return self.xdoc.toprettyxml()
def get_value_xpath(self, xpathStr):
- node = self.get_node(xpathStr)
+ try:
+ node = self.get_node(xpathStr)
+ except LoopUpError:
+ raise Exception('Zero or multiple node found')
+ return None
+
if node.nodeType == Node.ATTRIBUTE_NODE:
return node.value
if node.nodeType == Node.TEXT_NODE: