From cf58bceb559b56a46d9b4f6ba4f5aa5da927ecac Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 27 Dec 2020 00:49:46 +0100 Subject: xmltab: Remove safeJID(). --- poezio/tabs/xmltab.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'poezio/tabs/xmltab.py') diff --git a/poezio/tabs/xmltab.py b/poezio/tabs/xmltab.py index 2611d9d5..c765278f 100644 --- a/poezio/tabs/xmltab.py +++ b/poezio/tabs/xmltab.py @@ -10,7 +10,8 @@ log = logging.getLogger(__name__) import curses import os -from slixmpp.xmlstream import matcher +from slixmpp import JID, InvalidJID +from slixmpp.xmlstream import matcher, StanzaBase from slixmpp.xmlstream.tostring import tostring from slixmpp.xmlstream.stanzabase import ElementBase from xml.etree import ElementTree as ET @@ -21,7 +22,6 @@ from poezio import text_buffer from poezio import windows from poezio.xhtml import clean_text from poezio.decorators import command_args_parser, refresh_wrapper -from poezio.common import safeJID class MatchJID: @@ -29,9 +29,9 @@ class MatchJID: self.jid = jid self.dest = dest - def match(self, xml): - from_ = safeJID(xml['from']) - to_ = safeJID(xml['to']) + def match(self, xml: StanzaBase): + from_ = xml['from'] + to_ = xml['to'] if self.jid.full == self.jid.bare: from_ = from_.bare to_ = to_.bare @@ -190,33 +190,36 @@ class XMLTab(Tab): self.command_filter_reset() @command_args_parser.raw - def command_filter_to(self, jid): + def command_filter_to(self, jid_str: str): """/filter_jid_to """ - jid_obj = safeJID(jid) - if not jid_obj: + try: + jid = JID(jid_str) + except InvalidJID: return self.core.information('Invalid JID: %s' % jid, 'Error') - self.update_filters(MatchJID(jid_obj, dest='to')) + self.update_filters(MatchJID(jid, dest='to')) self.refresh() @command_args_parser.raw - def command_filter_from(self, jid): + def command_filter_from(self, jid_str: str): """/filter_jid_from """ - jid_obj = safeJID(jid) - if not jid_obj: + try: + jid = JID(jid_str) + except InvalidJID: return self.core.information('Invalid JID: %s' % jid, 'Error') - self.update_filters(MatchJID(jid_obj, dest='from')) + self.update_filters(MatchJID(jid, dest='from')) self.refresh() @command_args_parser.raw - def command_filter_jid(self, jid): + def command_filter_jid(self, jid_str: str): """/filter_jid """ - jid_obj = safeJID(jid) - if not jid_obj: + try: + jid = JID(jid_str) + except InvalidJID: return self.core.information('Invalid JID: %s' % jid, 'Error') - self.update_filters(MatchJID(jid_obj)) + self.update_filters(MatchJID(jid)) self.refresh() @command_args_parser.quoted(1) -- cgit v1.2.3