Author: laukpe
Date: Mon Nov 24 03:12:21 2008
New Revision: 1076

Modified:
   trunk/src/robot/utils/etreedomwrapper.py

Log:
cleanup, must pass path to child nodes

Modified: trunk/src/robot/utils/etreedomwrapper.py
==============================================================================
--- trunk/src/robot/utils/etreedomwrapper.py    (original)
+++ trunk/src/robot/utils/etreedomwrapper.py    Mon Nov 24 03:12:21 2008
@@ -12,23 +12,21 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

-
 from StringIO import StringIO
 try:
     import xml.etree.cElementTree as ET
 except ImportError:
-    try:
-        import xml.etree.ElementTree as ET
+    try:
+        import cElementTree as ET
     except ImportError:
         try:
-            import cElementTree as ET
+            import xml.etree.ElementTree as ET
         except ImportError:
             import elementtree.ElementTree as ET

 from abstractdomwrapper import AbstractDomWrapper


-
 class DomWrapper(AbstractDomWrapper):

     """A wrapper for Python's XML DOM for simplifying reading data from it.
@@ -43,13 +41,13 @@
internally. 'path' may actually also be an already opened file object
         (or anything accepted by ElementTree.parse).
         """
-        # This should not be changed to if node:. See chapter Truth Testing
+        AbstractDomWrapper.__init__(self, path)
+ # This should NOT be changed to 'if node:'. See chapter Truth Testing
         # from http://effbot.org/zone/element.htm#the-element-type
         if node is None:
             node = ET.parse(path or StringIO(string)).getroot()
-        AbstractDomWrapper.__init__(self, path)
         self.name = node.tag
         self.attrs = dict(node.items())
-        self.text = node.text or self.text
+        self.text = node.text or ''
         for child in list(node):
-            self.children.append(DomWrapper(node=child))
+            self.children.append(DomWrapper(path, node=child))

Reply via email to