summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-09-20 16:45:29 +0900
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-09-20 16:45:29 +0900
commit3a9b45e4f279c430242f8d6f3ee7c9506ba0d208 (patch)
tree205a4d6e95af1a102facd9ddd42db887bffe1399
parentb8e091233e152572786080f21cdc8d1b844912ed (diff)
downloadslixmpp-3a9b45e4f279c430242f8d6f3ee7c9506ba0d208.tar.gz
slixmpp-3a9b45e4f279c430242f8d6f3ee7c9506ba0d208.tar.bz2
slixmpp-3a9b45e4f279c430242f8d6f3ee7c9506ba0d208.tar.xz
slixmpp-3a9b45e4f279c430242f8d6f3ee7c9506ba0d208.zip
ElementBase: Remove deprecated find() and findall() methods.disco
-rw-r--r--slixmpp/features/feature_mechanisms/stanza/mechanisms.py4
-rw-r--r--slixmpp/plugins/xep_0009/binding.py47
-rw-r--r--slixmpp/plugins/xep_0009/remote.py4
-rw-r--r--slixmpp/plugins/xep_0030/stanza/info.py12
-rw-r--r--slixmpp/plugins/xep_0030/stanza/items.py2
-rw-r--r--slixmpp/plugins/xep_0050/stanza.py4
-rw-r--r--slixmpp/plugins/xep_0059/stanza.py4
-rw-r--r--slixmpp/plugins/xep_0085/stanza.py4
-rw-r--r--slixmpp/plugins/xep_0184/stanza.py4
-rw-r--r--slixmpp/plugins/xep_0198/stanza.py4
-rw-r--r--slixmpp/plugins/xep_0325/control.py2
-rw-r--r--slixmpp/xmlstream/stanzabase.py30
12 files changed, 46 insertions, 75 deletions
diff --git a/slixmpp/features/feature_mechanisms/stanza/mechanisms.py b/slixmpp/features/feature_mechanisms/stanza/mechanisms.py
index 4437e155..064b8d1f 100644
--- a/slixmpp/features/feature_mechanisms/stanza/mechanisms.py
+++ b/slixmpp/features/feature_mechanisms/stanza/mechanisms.py
@@ -29,7 +29,7 @@ class Mechanisms(ElementBase):
"""
"""
results = []
- mechs = self.findall('{%s}mechanism' % self.namespace)
+ mechs = self.xml.findall('{%s}mechanism' % self.namespace)
if mechs:
for mech in mechs:
results.append(mech.text)
@@ -47,7 +47,7 @@ class Mechanisms(ElementBase):
def del_mechanisms(self):
"""
"""
- mechs = self.findall('{%s}mechanism' % self.namespace)
+ mechs = self.xml.findall('{%s}mechanism' % self.namespace)
if mechs:
for mech in mechs:
self.xml.remove(mech)
diff --git a/slixmpp/plugins/xep_0009/binding.py b/slixmpp/plugins/xep_0009/binding.py
index d922dfc7..31387b3f 100644
--- a/slixmpp/plugins/xep_0009/binding.py
+++ b/slixmpp/plugins/xep_0009/binding.py
@@ -25,7 +25,7 @@ def fault2xml(fault):
def xml2fault(params):
vals = []
- for value in params.findall('{%s}value' % _namespace):
+ for value in params.xml.findall('{%s}value' % _namespace):
vals.append(_xml2py(value))
fault = dict()
fault['code'] = vals[0]['faultCode']
@@ -92,39 +92,40 @@ def _py2xml(*args):
def xml2py(params):
namespace = 'jabber:iq:rpc'
vals = []
- for param in params.findall('{%s}param' % namespace):
+ for param in params.xml.findall('{%s}param' % namespace):
vals.append(_xml2py(param.find('{%s}value' % namespace)))
return vals
def _xml2py(value):
namespace = 'jabber:iq:rpc'
- if value.find('{%s}nil' % namespace) is not None:
+ find_value = value.xml.find
+ if find_value('{%s}nil' % namespace) is not None:
return None
- if value.find('{%s}i4' % namespace) is not None:
- return int(value.find('{%s}i4' % namespace).text)
- if value.find('{%s}int' % namespace) is not None:
- return int(value.find('{%s}int' % namespace).text)
- if value.find('{%s}boolean' % namespace) is not None:
- return bool(int(value.find('{%s}boolean' % namespace).text))
- if value.find('{%s}string' % namespace) is not None:
- return value.find('{%s}string' % namespace).text
- if value.find('{%s}double' % namespace) is not None:
- return float(value.find('{%s}double' % namespace).text)
- if value.find('{%s}base64' % namespace) is not None:
- return rpcbase64(value.find('{%s}base64' % namespace).text.encode())
- if value.find('{%s}Base64' % namespace) is not None:
+ if find_value('{%s}i4' % namespace) is not None:
+ return int(find_value('{%s}i4' % namespace).text)
+ if find_value('{%s}int' % namespace) is not None:
+ return int(find_value('{%s}int' % namespace).text)
+ if find_value('{%s}boolean' % namespace) is not None:
+ return bool(int(find_value('{%s}boolean' % namespace).text))
+ if find_value('{%s}string' % namespace) is not None:
+ return find_value('{%s}string' % namespace).text
+ if find_value('{%s}double' % namespace) is not None:
+ return float(find_value('{%s}double' % namespace).text)
+ if find_value('{%s}base64' % namespace) is not None:
+ return rpcbase64(find_value('{%s}base64' % namespace).text.encode())
+ if find_value('{%s}Base64' % namespace) is not None:
# Older versions of XEP-0009 used Base64
- return rpcbase64(value.find('{%s}Base64' % namespace).text.encode())
- if value.find('{%s}dateTime.iso8601' % namespace) is not None:
- return rpctime(value.find('{%s}dateTime.iso8601' % namespace).text)
- if value.find('{%s}struct' % namespace) is not None:
+ return rpcbase64(find_value('{%s}Base64' % namespace).text.encode())
+ if find_value('{%s}dateTime.iso8601' % namespace) is not None:
+ return rpctime(find_value('{%s}dateTime.iso8601' % namespace).text)
+ if find_value('{%s}struct' % namespace) is not None:
struct = {}
- for member in value.find('{%s}struct' % namespace).findall('{%s}member' % namespace):
+ for member in find_value('{%s}struct' % namespace).findall('{%s}member' % namespace):
struct[member.find('{%s}name' % namespace).text] = _xml2py(member.find('{%s}value' % namespace))
return struct
- if value.find('{%s}array' % namespace) is not None:
+ if find_value('{%s}array' % namespace) is not None:
array = []
- for val in value.find('{%s}array' % namespace).find('{%s}data' % namespace).findall('{%s}value' % namespace):
+ for val in find_value('{%s}array' % namespace).find('{%s}data' % namespace).findall('{%s}value' % namespace):
array.append(_xml2py(val))
return array
raise ValueError()
diff --git a/slixmpp/plugins/xep_0009/remote.py b/slixmpp/plugins/xep_0009/remote.py
index 9675c88d..a9f45486 100644
--- a/slixmpp/plugins/xep_0009/remote.py
+++ b/slixmpp/plugins/xep_0009/remote.py
@@ -163,7 +163,7 @@ class ACL:
@classmethod
def _next_token(cls, expression, index):
- new_index = expression.find('*', index)
+ new_index = expression.xml.find('*', index)
if new_index == 0:
return ''
else:
@@ -182,7 +182,7 @@ class ACL:
#! print "[TOKEN] '%s'" % token
size = len(token)
if size > 0:
- token_index = value.find(token, position)
+ token_index = value.xml.find(token, position)
if token_index == -1:
return False
else:
diff --git a/slixmpp/plugins/xep_0030/stanza/info.py b/slixmpp/plugins/xep_0030/stanza/info.py
index 39ee83d5..614b68de 100644
--- a/slixmpp/plugins/xep_0030/stanza/info.py
+++ b/slixmpp/plugins/xep_0030/stanza/info.py
@@ -137,7 +137,7 @@ class DiscoInfo(ElementBase):
identity = (category, itype, lang)
if identity in self._identities:
self._identities.remove(identity)
- for id_xml in self.findall('{%s}identity' % self.namespace):
+ for id_xml in self.xml.findall('{%s}identity' % self.namespace):
id = (id_xml.attrib['category'],
id_xml.attrib['type'],
id_xml.attrib.get('{%s}lang' % self.xml_ns, None))
@@ -163,7 +163,7 @@ class DiscoInfo(ElementBase):
identities = set()
else:
identities = []
- for id_xml in self.findall('{%s}identity' % self.namespace):
+ for id_xml in self.xml.findall('{%s}identity' % self.namespace):
xml_lang = id_xml.attrib.get('{%s}lang' % self.xml_ns, None)
if lang is None or xml_lang == lang:
id = (id_xml.attrib['category'],
@@ -205,7 +205,7 @@ class DiscoInfo(ElementBase):
Arguments:
lang -- Optional, standard xml:lang value.
"""
- for id_xml in self.findall('{%s}identity' % self.namespace):
+ for id_xml in self.xml.findall('{%s}identity' % self.namespace):
if lang is None:
self.xml.remove(id_xml)
elif id_xml.attrib.get('{%s}lang' % self.xml_ns, None) == lang:
@@ -239,7 +239,7 @@ class DiscoInfo(ElementBase):
"""
if feature in self._features:
self._features.remove(feature)
- for feature_xml in self.findall('{%s}feature' % self.namespace):
+ for feature_xml in self.xml.findall('{%s}feature' % self.namespace):
if feature_xml.attrib['var'] == feature:
self.xml.remove(feature_xml)
return True
@@ -251,7 +251,7 @@ class DiscoInfo(ElementBase):
features = set()
else:
features = []
- for feature_xml in self.findall('{%s}feature' % self.namespace):
+ for feature_xml in self.xml.findall('{%s}feature' % self.namespace):
if dedupe:
features.add(feature_xml.attrib['var'])
else:
@@ -272,5 +272,5 @@ class DiscoInfo(ElementBase):
def del_features(self):
"""Remove all features."""
self._features = set()
- for feature_xml in self.findall('{%s}feature' % self.namespace):
+ for feature_xml in self.xml.findall('{%s}feature' % self.namespace):
self.xml.remove(feature_xml)
diff --git a/slixmpp/plugins/xep_0030/stanza/items.py b/slixmpp/plugins/xep_0030/stanza/items.py
index 0e238492..314ab9b3 100644
--- a/slixmpp/plugins/xep_0030/stanza/items.py
+++ b/slixmpp/plugins/xep_0030/stanza/items.py
@@ -95,7 +95,7 @@ class DiscoItems(ElementBase):
node -- Optional extra identifying information.
"""
if (jid, node) in self._items:
- for item_xml in self.findall('{%s}item' % self.namespace):
+ for item_xml in self.xml.findall('{%s}item' % self.namespace):
item = (item_xml.attrib['jid'],
item_xml.attrib.get('node', None))
if item == (jid, node):
diff --git a/slixmpp/plugins/xep_0050/stanza.py b/slixmpp/plugins/xep_0050/stanza.py
index 9bae7d15..128a75cd 100644
--- a/slixmpp/plugins/xep_0050/stanza.py
+++ b/slixmpp/plugins/xep_0050/stanza.py
@@ -100,7 +100,7 @@ class Command(ElementBase):
self.del_actions()
if values:
self._set_sub_text('{%s}actions' % self.namespace, '', True)
- actions = self.find('{%s}actions' % self.namespace)
+ actions = self.xml.find('{%s}actions' % self.namespace)
for val in values:
if val in self.next_actions:
action = ET.Element('{%s}%s' % (self.namespace, val))
@@ -111,7 +111,7 @@ class Command(ElementBase):
Return the set of allowable next actions.
"""
actions = set()
- actions_xml = self.find('{%s}actions' % self.namespace)
+ actions_xml = self.xml.find('{%s}actions' % self.namespace)
if actions_xml is not None:
for action in self.next_actions:
action_xml = actions_xml.find('{%s}%s' % (self.namespace,
diff --git a/slixmpp/plugins/xep_0059/stanza.py b/slixmpp/plugins/xep_0059/stanza.py
index e2701af4..3843bc85 100644
--- a/slixmpp/plugins/xep_0059/stanza.py
+++ b/slixmpp/plugins/xep_0059/stanza.py
@@ -70,7 +70,7 @@ class Set(ElementBase):
'count', 'index', 'last', 'max'))
def set_first_index(self, val):
- fi = self.find("{%s}first" % (self.namespace))
+ fi = self.xml.find("{%s}first" % (self.namespace))
if fi is not None:
if val:
fi.attrib['index'] = val
@@ -82,7 +82,7 @@ class Set(ElementBase):
self.xml.append(fi)
def get_first_index(self):
- fi = self.find("{%s}first" % (self.namespace))
+ fi = self.xml.find("{%s}first" % (self.namespace))
if fi is not None:
return fi.attrib.get('index', '')
diff --git a/slixmpp/plugins/xep_0085/stanza.py b/slixmpp/plugins/xep_0085/stanza.py
index d1a5b151..de1bc645 100644
--- a/slixmpp/plugins/xep_0085/stanza.py
+++ b/slixmpp/plugins/xep_0085/stanza.py
@@ -50,7 +50,7 @@ class ChatState(ElementBase):
def get_chat_state(self):
parent = self.parent()
for state in self.states:
- state_xml = parent.find('{%s}%s' % (self.namespace, state))
+ state_xml = parent.xml.find('{%s}%s' % (self.namespace, state))
if state_xml is not None:
self.xml = state_xml
return state
@@ -68,7 +68,7 @@ class ChatState(ElementBase):
def del_chat_state(self):
parent = self.parent()
for state in self.states:
- state_xml = parent.find('{%s}%s' % (self.namespace, state))
+ state_xml = parent.xml.find('{%s}%s' % (self.namespace, state))
if state_xml is not None:
self.xml = ET.Element('')
parent.xml.remove(state_xml)
diff --git a/slixmpp/plugins/xep_0184/stanza.py b/slixmpp/plugins/xep_0184/stanza.py
index 16a640e7..03a0ff9c 100644
--- a/slixmpp/plugins/xep_0184/stanza.py
+++ b/slixmpp/plugins/xep_0184/stanza.py
@@ -32,7 +32,7 @@ class Request(ElementBase):
def get_request_receipt(self):
parent = self.parent()
- if parent.find("{%s}request" % self.namespace) is not None:
+ if parent.xml.find("{%s}request" % self.namespace) is not None:
return True
else:
return False
@@ -63,7 +63,7 @@ class Received(ElementBase):
def get_receipt(self):
parent = self.parent()
- xml = parent.find("{%s}received" % self.namespace)
+ xml = parent.xml.find("{%s}received" % self.namespace)
if xml is not None:
return xml.attrib.get('id', '')
return ''
diff --git a/slixmpp/plugins/xep_0198/stanza.py b/slixmpp/plugins/xep_0198/stanza.py
index b1c4c010..5b13293b 100644
--- a/slixmpp/plugins/xep_0198/stanza.py
+++ b/slixmpp/plugins/xep_0198/stanza.py
@@ -99,7 +99,7 @@ class StreamManagement(ElementBase):
interfaces = set(['required', 'optional'])
def get_required(self):
- return self.find('{%s}required' % self.namespace) is not None
+ return self.xml.find('{%s}required' % self.namespace) is not None
def set_required(self, val):
self.del_required()
@@ -110,7 +110,7 @@ class StreamManagement(ElementBase):
self._del_sub('required')
def get_optional(self):
- return self.find('{%s}optional' % self.namespace) is not None
+ return self.xml.find('{%s}optional' % self.namespace) is not None
def set_optional(self, val):
self.del_optional()
diff --git a/slixmpp/plugins/xep_0325/control.py b/slixmpp/plugins/xep_0325/control.py
index 9a493b02..5c1b3003 100644
--- a/slixmpp/plugins/xep_0325/control.py
+++ b/slixmpp/plugins/xep_0325/control.py
@@ -540,7 +540,7 @@ class XEP_0325(BasePlugin):
fields = [f['name'] for f in iq['setResponse']['datas']]
error_msg = None
- if not iq['setResponse'].find('error') is None and not iq['setResponse']['error']['text'] == "":
+ if not iq['setResponse'].xml.find('error') is None and not iq['setResponse']['error']['text'] == "":
error_msg = iq['setResponse']['error']['text']
callback = self.sessions[seqnr]["callback"]
diff --git a/slixmpp/xmlstream/stanzabase.py b/slixmpp/xmlstream/stanzabase.py
index 612acd93..24e4e3ef 100644
--- a/slixmpp/xmlstream/stanzabase.py
+++ b/slixmpp/xmlstream/stanzabase.py
@@ -1123,36 +1123,6 @@ class ElementBase(object):
# Everything matched.
return True
- def find(self, xpath):
- """Find an XML object in this stanza given an XPath expression.
-
- Exposes ElementTree interface for backwards compatibility.
-
- .. note::
-
- Matching on attribute values is not supported in Python 2.6
- or Python 3.1
-
- :param string xpath: An XPath expression matching a single
- desired element.
- """
- return self.xml.find(xpath)
-
- def findall(self, xpath):
- """Find multiple XML objects in this stanza given an XPath expression.
-
- Exposes ElementTree interface for backwards compatibility.
-
- .. note::
-
- Matching on attribute values is not supported in Python 2.6
- or Python 3.1.
-
- :param string xpath: An XPath expression matching multiple
- desired elements.
- """
- return self.xml.findall(xpath)
-
def get(self, key, default=None):
"""Return the value of a stanza interface.