]> granicus.if.org Git - python/commitdiff
Jacques Frechet's and John Reese's simplification of ElementTree: give up
authorAlex Martelli <aleaxit@gmail.com>
Mon, 21 Aug 2006 23:45:19 +0000 (23:45 +0000)
committerAlex Martelli <aleaxit@gmail.com>
Mon, 21 Aug 2006 23:45:19 +0000 (23:45 +0000)
attempts at backwards compatibility which can't work anyway on Py3k (and aren't
needed for Python 2.5 and later).

Lib/xml/etree/ElementTree.py

index deaed7d27be1609790b660436ce3fbcc5a137397..e03e297050279442e7fd42d07d92e6ba26f66745 100644 (file)
@@ -111,33 +111,7 @@ __all__ = [
 
 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