Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6cefeb0

Browse files
committed
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).
1 parent 0008602 commit 6cefeb0

1 file changed

Lines changed: 1 addition & 27 deletions

File tree

Lib/xml/etree/ElementTree.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -111,33 +111,7 @@
111111

112112
import string, sys, re
113113

114-
class _SimpleElementPath:
115-
# emulate pre-1.2 find/findtext/findall behaviour
116-
def find(self, element, tag):
117-
for elem in element:
118-
if elem.tag == tag:
119-
return elem
120-
return None
121-
def findtext(self, element, tag, default=None):
122-
for elem in element:
123-
if elem.tag == tag:
124-
return elem.text or ""
125-
return default
126-
def findall(self, element, tag):
127-
if tag[:3] == ".//":
128-
return element.getiterator(tag[3:])
129-
result = []
130-
for elem in element:
131-
if elem.tag == tag:
132-
result.append(elem)
133-
return result
134-
135-
try:
136-
from . import ElementPath
137-
except ImportError:
138-
# FIXME: issue warning in this case?
139-
# TODO: DEFINITELY issue warning here!!!
140-
ElementPath = _SimpleElementPath()
114+
from . import ElementPath
141115

142116
# TODO: add support for custom namespace resolvers/default namespaces
143117
# TODO: add improved support for incremental parsing

0 commit comments

Comments
 (0)