Mercurial > libervia-web
changeset 601:49ccfc22116c frontends_multi_profiles
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 07 Feb 2015 19:22:45 +0100 |
parents | 32dbbc941123 |
children | be3fd3874c3a |
files | src/browser/sat_browser/contact_list.py |
diffstat | 1 files changed, 14 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/browser/sat_browser/contact_list.py Fri Feb 06 17:53:01 2015 +0100 +++ b/src/browser/sat_browser/contact_list.py Sat Feb 07 19:22:45 2015 +0100 @@ -588,40 +588,20 @@ # self.updateVisibility(self._contacts_panel.contacts, self.groups.keys()) -def mayContainJID(iterable, item): - """Tells if the given item is in the iterable, works with JID. - - @param iterable(object): list, set or another iterable object - @param item (object): element - @return: bool - """ - # Pyjamas JID-friendly implementation of the "in" operator. Since our JID - # doesn't inherit from str, without this method the test would return True - # only when the objects references are the same. - if isinstance(item, jid.JID): - return hash(item) in [hash(other) for other in iterable if isinstance(other, jid.JID)] - return super(type(iterable), iterable).__contains__(self, item) - - -class JIDSet(set): - """JID set implementation for Pyjamas""" +class JIDList(list): + """JID-friendly list implementation for Pyjamas""" def __contains__(self, item): - return mayContainJID(self, item) - - -class JIDList(list): - """JID list implementation for Pyjamas""" - - def __contains__(self, item): - return mayContainJID(self, item) + """Tells if the list contains the given item. - -class JIDDict(dict): - """JID dict implementation for Pyjamas (a dict with JID keys)""" - - def __contains__(self, item): - return mayContainJID(self, item) - - def keys(self): - return JIDSet(dict.keys(self)) + @param item (object): element to check + @return: bool + """ + # Since our JID doesn't inherit from str/unicode, without this method + # the test would return True only when the objects references are the + # same. Tests have shown that the other iterable "set" and "dict" don't + # need this hack to reproduce the Twisted's behavior. + for other in self: + if other == item: + return True + return False