# HG changeset patch # User souliane # Date 1423333365 -3600 # Node ID 49ccfc22116c993edf8a9fcd1ed40c2cf0cb59e5 # Parent 32dbbc9411231d36c5c8af2d8a2f4d06c0965c5d browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed diff -r 32dbbc941123 -r 49ccfc22116c src/browser/sat_browser/contact_list.py --- 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