summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-10-10 14:51:18 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2019-10-10 14:58:44 +0200
commitd62a2170e1aef7a768522222d2f5f4d2a26d5a1b (patch)
treeff96cfbad4915acfb7932e590e93159bbd6fe83f
parent01bca5cccd9270d5d98c12c781db5046df99d845 (diff)
downloadpoezio-d62a2170e1aef7a768522222d2f5f4d2a26d5a1b.tar.gz
poezio-d62a2170e1aef7a768522222d2f5f4d2a26d5a1b.tar.bz2
poezio-d62a2170e1aef7a768522222d2f5f4d2a26d5a1b.tar.xz
poezio-d62a2170e1aef7a768522222d2f5f4d2a26d5a1b.zip
bookmarks: Convert specified jid to JID object if possible
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/bookmarks.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/poezio/bookmarks.py b/poezio/bookmarks.py
index ced6fde6..a812ef03 100644
--- a/poezio/bookmarks.py
+++ b/poezio/bookmarks.py
@@ -41,13 +41,20 @@ log = logging.getLogger(__name__)
class Bookmark:
def __init__(self,
- jid: JID,
+ jid: Union[JID, str],
name: Optional[str] = None,
autojoin=False,
nick: Optional[str] = None,
password: Optional[str] = None,
method='local') -> None:
- self.jid = jid
+ try:
+ if isinstance(jid, JID):
+ self.jid = jid
+ else:
+ self.jid = JID(jid)
+ except InvalidJID:
+ log.debug('Invalid JID %r provided for bookmark %r', jid, name)
+ raise
self.name = name or jid
self.autojoin = autojoin
self.nick = nick