summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2020-12-27 00:49:46 +0100
committerLink Mauve <linkmauve@linkmauve.fr>2020-12-28 19:10:52 +0100
commitcf58bceb559b56a46d9b4f6ba4f5aa5da927ecac (patch)
tree57b692c2c3db6a8eb430590dcce57ad3a430855a
parentc7bce6ba9749727105c720b19a71df0bd183ece4 (diff)
downloadpoezio-cf58bceb559b56a46d9b4f6ba4f5aa5da927ecac.tar.gz
poezio-cf58bceb559b56a46d9b4f6ba4f5aa5da927ecac.tar.bz2
poezio-cf58bceb559b56a46d9b4f6ba4f5aa5da927ecac.tar.xz
poezio-cf58bceb559b56a46d9b4f6ba4f5aa5da927ecac.zip
xmltab: Remove safeJID().
-rw-r--r--poezio/tabs/xmltab.py37
1 files changed, 20 insertions, 17 deletions
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>"""
- 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>"""
- 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>"""
- 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)