[Python-3000-checkins] r51457 - python/branches/p3yk/Lib/xml/etree/ElementTree.py

alex.martelli python-3000-checkins at python.org
Tue Aug 22 01:45:19 CEST 2006


Author: alex.martelli
Date: Tue Aug 22 01:45:19 2006
New Revision: 51457

Modified:
   python/branches/p3yk/Lib/xml/etree/ElementTree.py
Log:
Jacques Frechet's and John Reese's simplification of ElementTree: give up
attempts at backwards compatibility which can't work anyway on Py3k (and aren't
needed for Python 2.5 and later).



Modified: python/branches/p3yk/Lib/xml/etree/ElementTree.py
==============================================================================
--- python/branches/p3yk/Lib/xml/etree/ElementTree.py	(original)
+++ python/branches/p3yk/Lib/xml/etree/ElementTree.py	Tue Aug 22 01:45:19 2006
@@ -111,33 +111,7 @@
 
 import string, sys, re
 
-class _SimpleElementPath:
-    # emulate pre-1.2 find/findtext/findall behaviour
-    def find(self, element, tag):
-        for elem in element:
-            if elem.tag == tag:
-                return elem
-        return None
-    def findtext(self, element, tag, default=None):
-        for elem in element:
-            if elem.tag == tag:
-                return elem.text or ""
-        return default
-    def findall(self, element, tag):
-        if tag[:3] == ".//":
-            return element.getiterator(tag[3:])
-        result = []
-        for elem in element:
-            if elem.tag == tag:
-                result.append(elem)
-        return result
-
-try:
-    from . import ElementPath
-except ImportError:
-    # FIXME: issue warning in this case?
-    # TODO: DEFINITELY issue warning here!!!
-    ElementPath = _SimpleElementPath()
+from . import ElementPath
 
 # TODO: add support for custom namespace resolvers/default namespaces
 # TODO: add improved support for incremental parsing


More information about the Python-3000-checkins mailing list