Issue #11367: fix documentation of some find* methods in ElementTree

This commit is contained in:
Eli Bendersky 2013-03-12 06:08:04 -07:00
parent 21e52aad13
commit 981c3bde8d
3 changed files with 9 additions and 19 deletions

View File

@ -711,26 +711,17 @@ ElementTree Objects
.. method:: find(match) .. method:: find(match)
Finds the first toplevel element matching *match*. *match* may be a tag Same as :meth:`Element.find`, starting at the root of the tree.
name or path. Same as getroot().find(match). Returns the first matching
element, or ``None`` if no element was found.
.. method:: findall(match) .. method:: findall(match)
Finds all matching subelements, by tag name or path. Same as Same as :meth:`Element.findall`, starting at the root of the tree.
getroot().findall(match). *match* may be a tag name or path. Returns a
list containing all matching elements, in document order.
.. method:: findtext(match, default=None) .. method:: findtext(match, default=None)
Finds the element text for the first toplevel element with given tag. Same as :meth:`Element.findtext`, starting at the root of the tree.
Same as getroot().findtext(match). *match* may be a tag name or path.
*default* is the value to return if the element was not found. Returns
the text content of the first matching element, or the default value no
element was found. Note that if the element is found, but has no text
content, this method returns an empty string.
.. method:: getiterator(tag=None) .. method:: getiterator(tag=None)

View File

@ -683,8 +683,8 @@ class ElementTree(object):
return list(self.iter(tag)) return list(self.iter(tag))
## ##
# Finds the first toplevel element with given tag. # Same as getroot().find(path), starting at the root of the
# Same as getroot().find(path). # tree.
# #
# @param path What element to look for. # @param path What element to look for.
# @keyparam namespaces Optional namespace prefix map. # @keyparam namespaces Optional namespace prefix map.
@ -704,10 +704,9 @@ class ElementTree(object):
return self._root.find(path, namespaces) return self._root.find(path, namespaces)
## ##
# Finds the element text for the first toplevel element with given # Same as getroot().findtext(path), starting at the root of the tree.
# tag. Same as getroot().findtext(path).
# #
# @param path What toplevel element to look for. # @param path What element to look for.
# @param default What to return if the element was not found. # @param default What to return if the element was not found.
# @keyparam namespaces Optional namespace prefix map. # @keyparam namespaces Optional namespace prefix map.
# @return The text content of the first matching element, or the # @return The text content of the first matching element, or the
@ -729,8 +728,7 @@ class ElementTree(object):
return self._root.findtext(path, default, namespaces) return self._root.findtext(path, default, namespaces)
## ##
# Finds all toplevel elements with the given tag. # Same as getroot().findall(path), starting at the root of the tree.
# Same as getroot().findall(path).
# #
# @param path What element to look for. # @param path What element to look for.
# @keyparam namespaces Optional namespace prefix map. # @keyparam namespaces Optional namespace prefix map.

View File

@ -398,6 +398,7 @@ Janko Hauser
Rycharde Hawkes Rycharde Hawkes
Ben Hayden Ben Hayden
Jochen Hayek Jochen Hayek
Henrik Heimbuerger
Christian Heimes Christian Heimes
Thomas Heller Thomas Heller
Malte Helmert Malte Helmert