Remove usage of deprecated getchildren() method.
This commit is contained in:
@@ -151,8 +151,8 @@ class MatchXMLMask(MatcherBase):
|
||||
"""
|
||||
tag = tag.split('}')[-1]
|
||||
try:
|
||||
children = [c.tag.split('}')[-1] for c in xml.getchildren()]
|
||||
children = [c.tag.split('}')[-1] for c in xml]
|
||||
index = children.index(tag)
|
||||
except ValueError:
|
||||
return None
|
||||
return xml.getchildren()[index]
|
||||
return list(xml)[index]
|
||||
|
||||
@@ -77,10 +77,10 @@ class MatchXPath(MatcherBase):
|
||||
# Skip empty tag name artifacts from the cleanup phase.
|
||||
continue
|
||||
|
||||
children = [c.tag.split('}')[-1] for c in xml.getchildren()]
|
||||
children = [c.tag.split('}')[-1] for c in xml]
|
||||
try:
|
||||
index = children.index(tag)
|
||||
except ValueError:
|
||||
return False
|
||||
xml = xml.getchildren()[index]
|
||||
xml = list(xml)[index]
|
||||
return True
|
||||
|
||||
@@ -445,7 +445,7 @@ class ElementBase(object):
|
||||
return
|
||||
|
||||
# Initialize values using provided XML
|
||||
for child in self.xml.getchildren():
|
||||
for child in self.xml:
|
||||
if child.tag in self.plugin_tag_map:
|
||||
plugin_class = self.plugin_tag_map[child.tag]
|
||||
self.init_plugin(plugin_class.plugin_attrib,
|
||||
@@ -1050,8 +1050,7 @@ class ElementBase(object):
|
||||
if parent is None:
|
||||
parent = self.xml
|
||||
for element in elements:
|
||||
if element.tag == original_target or \
|
||||
not element.getchildren():
|
||||
if element.tag == original_target or not list(element):
|
||||
# Only delete the originally requested elements, and
|
||||
# any parent elements that have become empty.
|
||||
elem_lang = element.attrib.get('{%s}lang' % XML_NS,
|
||||
@@ -1491,7 +1490,7 @@ class StanzaBase(ElementBase):
|
||||
|
||||
def get_payload(self):
|
||||
"""Return a list of XML objects contained in the stanza."""
|
||||
return self.xml.getchildren()
|
||||
return list(self.xml)
|
||||
|
||||
def set_payload(self, value):
|
||||
"""Add XML content to the stanza.
|
||||
|
||||
@@ -107,7 +107,7 @@ def tostring(xml=None, xmlns='', stanza_ns='', stream=None,
|
||||
if xml.text:
|
||||
output.append(xml_escape(xml.text))
|
||||
if len(xml):
|
||||
for child in xml.getchildren():
|
||||
for child in xml:
|
||||
output.append(tostring(child, tag_xmlns, stanza_ns, stream))
|
||||
output.append("</%s>" % tag_name)
|
||||
elif xml.text:
|
||||
|
||||
Reference in New Issue
Block a user