comparison sat_frontends/quick_frontend/quick_contact_management.py @ 4037:524856bd7b19

massive refactoring to switch from camelCase to snake_case: historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents be6d91572633
children 4b842c1fb686
comparison
equal deleted inserted replaced
4036:c4464d7ae97b 4037:524856bd7b19
47 return 47 return
48 if entity.resource in self.__contactlist[entity.bare]["resources"]: 48 if entity.resource in self.__contactlist[entity.bare]["resources"]:
49 self.__contactlist[entity.bare]["resources"].remove(entity.resource) 49 self.__contactlist[entity.bare]["resources"].remove(entity.resource)
50 self.__contactlist[entity.bare]["resources"].append(entity.resource) 50 self.__contactlist[entity.bare]["resources"].append(entity.resource)
51 51
52 def getContFromGroup(self, group): 52 def get_cont_from_group(self, group):
53 """Return all contacts which are in given group""" 53 """Return all contacts which are in given group"""
54 result = [] 54 result = []
55 for contact in self.__contactlist: 55 for contact in self.__contactlist:
56 if "groups" in self.__contactlist[contact]: 56 if "groups" in self.__contactlist[contact]:
57 if group in self.__contactlist[contact]["groups"]: 57 if group in self.__contactlist[contact]["groups"]:
58 result.append(JID(contact)) 58 result.append(JID(contact))
59 return result 59 return result
60 60
61 def getAttr(self, entity, name): 61 def get_attr(self, entity, name):
62 """Return a specific attribute of contact, or all attributes 62 """Return a specific attribute of contact, or all attributes
63 @param entity: jid of the contact 63 @param entity: jid of the contact
64 @param name: name of the attribute 64 @param name: name of the attribute
65 @return: asked attribute""" 65 @return: asked attribute"""
66 if entity.bare in self.__contactlist: 66 if entity.bare in self.__contactlist:
71 return self.__contactlist[entity.bare][name] 71 return self.__contactlist[entity.bare][name]
72 else: 72 else:
73 log.debug(_("Trying to get attribute for an unknown contact")) 73 log.debug(_("Trying to get attribute for an unknown contact"))
74 return None 74 return None
75 75
76 def isConnected(self, entity): 76 def is_connected(self, entity):
77 """Tell if the contact is online""" 77 """Tell if the contact is online"""
78 return entity.bare in self.__contactlist 78 return entity.bare in self.__contactlist
79 79
80 def remove(self, entity): 80 def remove(self, entity):
81 """remove resource. If no more resource is online or is no resource is specified, contact is deleted""" 81 """remove resource. If no more resource is online or is no resource is specified, contact is deleted"""