summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-10-26 00:57:20 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2019-10-26 00:57:20 +0200
commit4703c8506a7483650d0237a5def29ceed79f0c4a (patch)
treed7f76363f4895725adadddb6d40744ddc1c3210c
parentea1ab71f0252d788c93315422cc04f5db28d7698 (diff)
downloadpoezio-4703c8506a7483650d0237a5def29ceed79f0c4a.tar.gz
poezio-4703c8506a7483650d0237a5def29ceed79f0c4a.tar.bz2
poezio-4703c8506a7483650d0237a5def29ceed79f0c4a.tar.xz
poezio-4703c8506a7483650d0237a5def29ceed79f0c4a.zip
Bookmark: Change jid property to getter/setter to ensure it stays a JID
It's not like static-type checking was a thing in Python nowadays.. (mypy I'm looking at you) Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/bookmarks.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/poezio/bookmarks.py b/poezio/bookmarks.py
index 074566cd..ccda2b93 100644
--- a/poezio/bookmarks.py
+++ b/poezio/bookmarks.py
@@ -49,19 +49,35 @@ class Bookmark:
method='local') -> None:
try:
if isinstance(jid, JID):
- self.jid = jid
+ self._jid = jid
else:
- self.jid = JID(jid)
+ self._jid = JID(jid)
except InvalidJID:
- log.debug('Invalid JID %r provided for bookmark %r', jid, name)
+ log.debug('Invalid JID %r provided for bookmark', jid)
raise
- self.name = name or str(jid)
+ self.name = name or str(self.jid)
self.autojoin = autojoin
self.nick = nick
self.password = password
self._method = method
@property
+ def jid(self) -> JID:
+ """Jid getter"""
+ return self._jid
+
+ @jid.setter
+ def jid(self, jid: JID) -> None:
+ try:
+ if isinstance(jid, JID):
+ self._jid = jid
+ else:
+ self._jid = JID(jid)
+ except InvalidJID:
+ log.debug('Invalid JID %r provided for bookmark', jid)
+ raise
+
+ @property
def method(self) -> str:
return self._method