From 5a5c1fe9920f0a6c571e8c33f650371879de35dd Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 20 Sep 2016 16:29:55 +0900 Subject: Stop using deprecated aliases from slixmpp. --- poezio/common.py | 5 +++-- poezio/core/core.py | 2 +- poezio/core/handlers.py | 8 ++++---- poezio/fixes.py | 2 +- poezio/multiuserchat.py | 2 +- poezio/tabs/muctab.py | 22 +++++++++++----------- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/poezio/common.py b/poezio/common.py index 85bbdffe..4eff202c 100644 --- a/poezio/common.py +++ b/poezio/common.py @@ -249,14 +249,15 @@ def find_delayed_tag(message): :rtype: :py:class:`tuple` """ - delay_tag = message.find('{urn:xmpp:delay}delay') + find_delay = message.xml.find + delay_tag = find_delay('{urn:xmpp:delay}delay') if delay_tag is not None: delayed = True date = _datetime_tuple(delay_tag.attrib['stamp']) else: # We support the OLD and deprecated XEP: http://xmpp.org/extensions/xep-0091.html # But it sucks, please, Jabber servers, don't do this :( - delay_tag = message.find('{jabber:x:delay}x') + delay_tag = find_delay('{jabber:x:delay}x') if delay_tag is not None: delayed = True date = _datetime_tuple(delay_tag.attrib['stamp']) diff --git a/poezio/core/core.py b/poezio/core/core.py index b3aea9a6..6d20fdf7 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -928,7 +928,7 @@ class Core(object): Takes a stanza of the form and return a well formed string containing the error informations """ - sender = stanza.attrib['from'] + sender = stanza['from'] msg = stanza['error']['type'] condition = stanza['error']['condition'] code = stanza['error']['code'] diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index e8f1dd68..cf1c71f5 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -146,7 +146,7 @@ class HandlerCore: if jid.bare in self.core.pending_invites: return # there are 2 'x' tags in the messages, making message['x'] useless - invite = StanzaBase(self.core.xmpp, xml=message.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite')) + invite = StanzaBase(self.core.xmpp, xml=message.xml.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite')) inviter = invite['from'] reason = invite['reason'] password = invite['password'] @@ -200,7 +200,7 @@ class HandlerCore: When receiving private message from a muc OR a normal message (from one of our contacts) """ - if message.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite') != None: + if message.xml.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}invite') != None: return if message['type'] == 'groupchat': return @@ -1025,7 +1025,7 @@ class HandlerCore: """ room_from = message['from'] tab = self.core.get_tab_by_name(room_from, tabs.MucTab) - status_codes = set([s.attrib['code'] for s in message.findall('{%s}x/{%s}status' % (tabs.NS_MUC_USER, tabs.NS_MUC_USER))]) + status_codes = {s.attrib['code'] for s in message.xml.findall('{%s}x/{%s}status' % (tabs.NS_MUC_USER, tabs.NS_MUC_USER))} if '101' in status_codes: self.core.information('Your affiliation in the room %s changed' % room_from, 'Info') elif tab and status_codes: @@ -1312,7 +1312,7 @@ class HandlerCore: status = iq['command']['status'] xform = iq.xml.find('{http://jabber.org/protocol/commands}command/{jabber:x:data}x') if xform is not None: - form = self.core.xmpp.plugin['xep_0004'].buildForm(xform) + form = self.core.xmpp.plugin['xep_0004'].build_form(xform) else: form = None diff --git a/poezio/fixes.py b/poezio/fixes.py index 3840a093..8259f5db 100644 --- a/poezio/fixes.py +++ b/poezio/fixes.py @@ -45,7 +45,7 @@ def get_room_form(xmpp, room, callback): xform = result.xml.find('{http://jabber.org/protocol/muc#owner}query/{jabber:x:data}x') if xform is None: return callback(None) - form = xmpp.plugin['xep_0004'].buildForm(xform) + form = xmpp.plugin['xep_0004'].build_form(xform) return callback(form) iq = xmpp.make_iq_get(ito=room) diff --git a/poezio/multiuserchat.py b/poezio/multiuserchat.py index 9f231b2f..90d03572 100644 --- a/poezio/multiuserchat.py +++ b/poezio/multiuserchat.py @@ -189,7 +189,7 @@ def configure_room(xmpp, room, form): iq = xmpp.make_iq_set() iq['to'] = room query = ET.Element('{http://jabber.org/protocol/muc#owner}query') - form = form.getXML('submit') + form['type'] = 'submit' query.append(form) iq.append(query) iq.send() diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index a6a87580..6d1439c0 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -1085,7 +1085,7 @@ class MucTab(ChatTab): from_room = presence['from'].bare xpath = '{%s}x/{%s}status' % (NS_MUC_USER, NS_MUC_USER) status_codes = set() - for status_code in presence.findall(xpath): + for status_code in presence.xml.findall(xpath): status_codes.add(status_code.attrib['code']) # Check if it's not an error presence. @@ -1280,8 +1280,8 @@ class MucTab(ChatTab): self.core.on_user_rejoined_private_conversation(self.name, from_nick) def on_user_nick_change(self, presence, user, from_nick, from_room): - new_nick = presence.find('{%s}x/{%s}item' % (NS_MUC_USER, NS_MUC_USER) - ).attrib['nick'] + new_nick = presence.xml.find('{%s}x/{%s}item' % (NS_MUC_USER, NS_MUC_USER) + ).attrib['nick'] if user.nick == self.own_nick: self.own_nick = new_nick # also change our nick in all private discussions of this room @@ -1315,10 +1315,10 @@ class MucTab(ChatTab): When someone is banned from a muc """ self.users.remove(user) - by = presence.find('{%s}x/{%s}item/{%s}actor' % - (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) - reason = presence.find('{%s}x/{%s}item/{%s}reason' % - (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) + by = presence.xml.find('{%s}x/{%s}item/{%s}actor' % + (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) + reason = presence.xml.find('{%s}x/{%s}item/{%s}reason' % + (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) by = by.attrib['jid'] if by is not None else None info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) @@ -1383,10 +1383,10 @@ class MucTab(ChatTab): When someone is kicked from a muc """ self.users.remove(user) - actor_elem = presence.find('{%s}x/{%s}item/{%s}actor' % - (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) - reason = presence.find('{%s}x/{%s}item/{%s}reason' % - (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) + actor_elem = presence.xml.find('{%s}x/{%s}item/{%s}actor' % + (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) + reason = presence.xml.find('{%s}x/{%s}item/{%s}reason' % + (NS_MUC_USER, NS_MUC_USER, NS_MUC_USER)) by = None info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT) char_kick = get_theme().CHAR_KICK -- cgit v1.2.3