diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2019-10-10 14:51:18 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2019-10-10 14:58:44 +0200 |
commit | d62a2170e1aef7a768522222d2f5f4d2a26d5a1b (patch) | |
tree | ff96cfbad4915acfb7932e590e93159bbd6fe83f | |
parent | 01bca5cccd9270d5d98c12c781db5046df99d845 (diff) | |
download | poezio-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.py | 11 |
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 |