diff options
author | mathieui <mathieui@mathieui.net> | 2012-08-06 15:38:09 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-08-06 15:38:09 +0200 |
commit | 7a485ef4d0d74313bff8c9c7b2ee2dcb5c4a75e9 (patch) | |
tree | 293d3c01239572dd3a9743422c79f8c0dfdc0a1c /src/contact.py | |
parent | a14141bcec98eee77937716113ecd8a994c4836b (diff) | |
download | poezio-7a485ef4d0d74313bff8c9c7b2ee2dcb5c4a75e9.tar.gz poezio-7a485ef4d0d74313bff8c9c7b2ee2dcb5c4a75e9.tar.bz2 poezio-7a485ef4d0d74313bff8c9c7b2ee2dcb5c4a75e9.tar.xz poezio-7a485ef4d0d74313bff8c9c7b2ee2dcb5c4a75e9.zip |
Add a common.safeJID function, and use it everywhere
Diffstat (limited to 'src/contact.py')
-rw-r--r-- | src/contact.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/contact.py b/src/contact.py index b8963a71..7111b1da 100644 --- a/src/contact.py +++ b/src/contact.py @@ -13,7 +13,8 @@ the roster. import logging log = logging.getLogger(__name__) -from sleekxmpp.xmlstream import JID +from sleekxmpp import JID +from common import safeJID class Resource(object): """ @@ -24,7 +25,7 @@ class Resource(object): """ data: the dict to use as a source """ - self._jid = JID(jid) # Full jid + self._jid = safeJID(jid) # Full jid self._data = data @property @@ -110,7 +111,7 @@ class Contact(object): return self.__item['subscription'] def __contains__(self, value): - return value in self.__item.resources or JID(value).resource in self.__item.resources + return value in self.__item.resources or safeJID(value).resource in self.__item.resources def __len__(self): """Number of resources""" @@ -122,7 +123,7 @@ class Contact(object): def __getitem__(self, key): """Return the corresponding Resource object, or None""" - res = JID(key).resource + res = safeJID(key).resource resources = self.__item.resources item = resources.get(res, None) or resources.get(key, None) return Resource(key, item) if item else None |