summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-04-27 19:39:18 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2019-04-27 19:39:18 +0100
commit0a4781134e620079c6788d47616fc4bfa99e0321 (patch)
tree9b13d7d98df617c511ae532daa346c523340d924
parentdc9edb101fc0d2481183f85858f22fe77d535cee (diff)
downloadpoezio-0a4781134e620079c6788d47616fc4bfa99e0321.tar.gz
poezio-0a4781134e620079c6788d47616fc4bfa99e0321.tar.bz2
poezio-0a4781134e620079c6788d47616fc4bfa99e0321.tar.xz
poezio-0a4781134e620079c6788d47616fc4bfa99e0321.zip
ChatTab: now accepts only Jids with a domain
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/tabs/basetabs.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index a1c3f8d4..376f411a 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -464,9 +464,13 @@ class ChatTab(Tab):
def __init__(self, core, jid: Union[JID, str]):
Tab.__init__(self, core)
- self._jid = None
- self._name = ''
- self.name = jid
+
+ if not isinstance(jid, JID):
+ jid = JID(jid)
+ assert jid.domain
+ self._jid = jid
+
+ self._name = jid.full
self.text_win = None
self.directed_presence = None
self._text_buffer = TextBuffer()
@@ -533,18 +537,14 @@ class ChatTab(Tab):
raise TypeError("Name must be of type JID or str.")
@property
- def jid(self) -> Optional[JID]:
+ def jid(self) -> JID:
return self._jid
@jid.setter
- def jid(self, value: Optional[JID]) -> None:
- if value is None:
- self._jid = None
- return None
+ def jid(self, value: JID) -> None:
if not isinstance(value, JID):
- raise TypeError("Jid must be of type Optional[JID].")
- if not value.domain:
- raise ValueError("Jid must contain at least a domain.")
+ raise TypeError("Jid %r must be of type JID." % value)
+ assert value.domain
self._jid = value
@property