diff sat_frontends/quick_frontend/quick_contact_management.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
line wrap: on
line diff
--- a/sat_frontends/quick_frontend/quick_contact_management.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat_frontends/quick_frontend/quick_contact_management.py	Wed Jun 27 20:14:46 2018 +0200
@@ -19,12 +19,14 @@
 
 from sat.core.i18n import _
 from sat.core.log import getLogger
+
 log = getLogger(__name__)
-from sat_frontends.tools.jid  import JID
+from sat_frontends.tools.jid import JID
 
 
 class QuickContactManagement(object):
     """This helper class manage the contacts and ease the use of nicknames and shortcuts"""
+
     ### FIXME: is SàT a better place for all this stuff ??? ###
 
     def __init__(self):
@@ -40,19 +42,19 @@
     def add(self, entity):
         """Add contact to the list, update resources"""
         if not self.__contactlist.has_key(entity.bare):
-            self.__contactlist[entity.bare] = {'resources':[]}
+            self.__contactlist[entity.bare] = {"resources": []}
         if not entity.resource:
             return
-        if entity.resource in self.__contactlist[entity.bare]['resources']:
-            self.__contactlist[entity.bare]['resources'].remove(entity.resource)
-        self.__contactlist[entity.bare]['resources'].append(entity.resource)
+        if entity.resource in self.__contactlist[entity.bare]["resources"]:
+            self.__contactlist[entity.bare]["resources"].remove(entity.resource)
+        self.__contactlist[entity.bare]["resources"].append(entity.resource)
 
     def getContFromGroup(self, group):
         """Return all contacts which are in given group"""
         result = []
         for contact in self.__contactlist:
-            if self.__contactlist[contact].has_key('groups'):
-                if group in self.__contactlist[contact]['groups']:
+            if self.__contactlist[contact].has_key("groups"):
+                if group in self.__contactlist[contact]["groups"]:
                     result.append(JID(contact))
         return result
 
@@ -62,13 +64,13 @@
         @param name: name of the attribute
         @return: asked attribute"""
         if self.__contactlist.has_key(entity.bare):
-            if name == 'status':  #FIXME: for the moment, we only use the first status
-                if self.__contactlist[entity.bare]['statuses']:
-                    return self.__contactlist[entity.bare]['statuses'].values()[0]
+            if name == "status":  # FIXME: for the moment, we only use the first status
+                if self.__contactlist[entity.bare]["statuses"]:
+                    return self.__contactlist[entity.bare]["statuses"].values()[0]
             if self.__contactlist[entity.bare].has_key(name):
                 return self.__contactlist[entity.bare][name]
         else:
-            log.debug(_('Trying to get attribute for an unknown contact'))
+            log.debug(_("Trying to get attribute for an unknown contact"))
         return None
 
     def isConnected(self, entity):
@@ -79,12 +81,12 @@
         """remove resource. If no more resource is online or is no resource is specified, contact is deleted"""
         try:
             if entity.resource:
-                self.__contactlist[entity.bare]['resources'].remove(entity.resource)
-            if not entity.resource or not self.__contactlist[entity.bare]['resources']:
-                #no more resource available: the contact seems really disconnected
+                self.__contactlist[entity.bare]["resources"].remove(entity.resource)
+            if not entity.resource or not self.__contactlist[entity.bare]["resources"]:
+                # no more resource available: the contact seems really disconnected
                 del self.__contactlist[entity.bare]
         except KeyError:
-            log.error(_('INTERNAL ERROR: Key log.error'))
+            log.error(_("INTERNAL ERROR: Key log.error"))
             raise
 
     def update(self, entity, key, value):
@@ -96,8 +98,7 @@
         if self.__contactlist.has_key(entity.bare):
             self.__contactlist[entity.bare][key] = value
         else:
-            log.debug (_('Trying to update an unknown contact: %s') % entity.bare)
+            log.debug(_("Trying to update an unknown contact: %s") % entity.bare)
 
     def get_full(self, entity):
-        return entity.bare+'/'+self.__contactlist[entity.bare]['resources'][-1]
-
+        return entity.bare + "/" + self.__contactlist[entity.bare]["resources"][-1]