diff frontends/src/wix/contact_list.py @ 1011:5a6354ff468c

wix: use of new logging system
author Goffi <goffi@goffi.org>
date Mon, 05 May 2014 20:12:21 +0200
parents 6f1e03068b5f
children 0a9986452bba
line wrap: on
line diff
--- a/frontends/src/wix/contact_list.py	Mon May 05 20:12:19 2014 +0200
+++ b/frontends/src/wix/contact_list.py	Mon May 05 20:12:21 2014 +0200
@@ -21,7 +21,8 @@
 import wx
 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList
 from sat_frontends.wix.constants import Const
-from logging import debug, info, error
+from sat.core.log import getLogger
+log = getLogger(__name__)
 from cgi import escape
 from sat.tools.jid  import JID
 from os.path import join
@@ -41,7 +42,7 @@
         @param parent: WxWidgets parent of the widget
         @param host: wix main app class
         @param type_: type of contact list: "JID" for the usual big jid contact list
-                                           "CUSTOM" for a customized contact list (self.__presentItem must then be overrided)
+                                           "CUSTOM" for a customized contact list (self._presentItem must then be overrided)
         """
         wx.SimpleHtmlListBox.__init__(self, parent, -1)
         QuickContactList.__init__(self)
@@ -58,9 +59,9 @@
 
     def __typeSwitch(self):
         if self.type == "JID":
-            self.__presentItem = self.__presentItemJID
-        elif type_ != "CUSTOM":
-            self.__presentItem = self.__presentItemDefault
+            self._presentItem = self._presentItemJID
+        elif self.type != "CUSTOM":
+            self._presentItem = self._presentItemDefault
 
     def __find_idx(self, entity):
         """Find indexes of given contact (or groups) in contact list, manage jid
@@ -84,12 +85,12 @@
 
         XXX: None value for 'groups' has a different meaning than [None] which is for the default group.
         """
-        debug(_("update %s") % contact)
+        log.debug(_("update %s") % contact)
         if not self.__find_idx(contact):
             self.add(contact, groups)
         else:
             for i in self.__find_idx(contact):
-                _present = self.__presentItem(contact)
+                _present = self._presentItem(contact)
                 if _present != None:
                     self.SetString(i, _present)
 
@@ -106,17 +107,17 @@
         return erased
 
 
-    def __presentGroup(self, group):
+    def _presentGroup(self, group):
         """Make a nice presentation for the contact groups"""
         html = u"""-- [%s] --""" % group
 
         return html
 
-    def __presentItemDefault(self, contact):
+    def _presentItemDefault(self, contact):
         """Make a basic presentation of string contacts in the list."""
         return contact
 
-    def __presentItemJID(self, jid):
+    def _presentItemJID(self, jid):
         """Make a nice presentation of the contact in the list for JID contacts."""
         name = self.getCache(jid,'name')
         nick = self.getCache(jid,'nick')
@@ -158,9 +159,9 @@
 
     def add(self, contact, groups = None):
         """add a contact to the list"""
-        debug (_("adding %s"),contact)
+        log.debug (_("adding %s"),contact)
         if not groups:
-            _present =  self.__presentItem(contact)
+            _present =  self._presentItem(contact)
             if _present:
                 idx = self.Insert(_present, 0, contact)
         else:
@@ -168,11 +169,11 @@
                 indexes = self.__find_idx(group)
                 gp_idx = 0
                 if not indexes:  #this is a new group, we have to create it
-                    gp_idx = self.Append(self.__presentGroup(group), Group(group))
+                    gp_idx = self.Append(self._presentGroup(group), Group(group))
                 else:
                     gp_idx = indexes[0]
 
-                _present = self.__presentItem(contact)
+                _present = self._presentItem(contact)
                 if _present:
                     self.Insert(_present, gp_idx+1, contact)
 
@@ -197,7 +198,7 @@
 
     def remove(self, contact):
         """remove a contact from the list"""
-        debug (_("removing %s"), contact)
+        log.debug (_("removing %s"), contact)
         list_idx = self.__find_idx(contact)
         list_idx.reverse()  #as we make some deletions, we have to reverse the order
         for i in list_idx:
@@ -215,7 +216,7 @@
                 contacts.sort()
                 id_insert = self.GetSelection()+1
                 for contact in contacts:
-                    _present =  self.__presentItem(contact)
+                    _present =  self._presentItem(contact)
                     if _present:
                         self.Insert(_present, id_insert, contact)
             self.SetSelection(wx.NOT_FOUND)