diff src/browser/sat_browser/contact_list.py @ 608:ea27925ef2a8 frontends_multi_profiles

merges souliane changes
author Goffi <goffi@goffi.org>
date Mon, 09 Feb 2015 21:58:49 +0100
parents 537649f6a2d0 49ccfc22116c
children 14bdf5394ae9
line wrap: on
line diff
--- a/src/browser/sat_browser/contact_list.py	Mon Feb 09 21:56:30 2015 +0100
+++ b/src/browser/sat_browser/contact_list.py	Mon Feb 09 21:58:49 2015 +0100
@@ -602,40 +602,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