Mercurial > libervia-backend
diff sat_frontends/jp/cmd_roster.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 | 4c3361e2bf55 |
children | 4b842c1fb686 |
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_roster.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat_frontends/jp/cmd_roster.py Sat Apr 08 13:54:42 2023 +0200 @@ -64,7 +64,7 @@ async def start(self): try: - contacts = await self.host.bridge.getContacts(profile_key=self.host.profile) + contacts = await self.host.bridge.contacts_get(profile_key=self.host.profile) except Exception as e: self.disp(f"error while retrieving the contacts: {e}", error=True) self.host.quit(C.EXIT_BRIDGE_ERRBACK) @@ -72,7 +72,7 @@ contacts_dict = {} for contact_jid_s, data, groups in contacts: # FIXME: we have to convert string to bool here for historical reason - # getContacts format should be changed and serialised properly + # contacts_get format should be changed and serialised properly for key in ('from', 'to', 'ask'): if key in data: data[key] = C.bool(data[key]) @@ -107,7 +107,7 @@ groups = self.args.groups else: try: - entity_data = await self.host.bridge.contactGet( + entity_data = await self.host.bridge.contact_get( self.args.jid, self.host.profile) except Exception as e: self.disp(f"error while retrieving the contact: {e}", error=True) @@ -117,7 +117,7 @@ groups = list(groups.union(self.args.groups)) try: - await self.host.bridge.updateContact( + await self.host.bridge.contact_update( self.args.jid, name, groups, self.host.profile) except Exception as e: self.disp(f"error while updating the contact: {e}", error=True) @@ -142,9 +142,9 @@ message = _("Are you sure to delete {entity} from your roster?").format( entity=self.args.jid ) - await self.host.confirmOrQuit(message, _("entity deletion cancelled")) + await self.host.confirm_or_quit(message, _("entity deletion cancelled")) try: - await self.host.bridge.delContact( + await self.host.bridge.contact_del( self.args.jid, self.host.profile) except Exception as e: self.disp(f"error while deleting the entity: {e}", error=True) @@ -162,7 +162,7 @@ async def start(self): try: - contacts = await self.host.bridge.getContacts(profile_key=self.host.profile) + contacts = await self.host.bridge.contacts_get(profile_key=self.host.profile) except Exception as e: self.disp(f"error while retrieving the contacts: {e}", error=True) self.host.quit(C.EXIT_BRIDGE_ERRBACK) @@ -235,7 +235,7 @@ async def start(self): try: - contacts = await self.host.bridge.getContacts(self.host.profile) + contacts = await self.host.bridge.contacts_get(self.host.profile) except Exception as e: self.disp(f"error while retrieving the contacts: {e}", error=True) self.host.quit(C.EXIT_BRIDGE_ERRBACK) @@ -258,7 +258,7 @@ elif await self.ask_confirmation(no_sub, no_from, no_to): for contact in no_sub + no_from + no_to: try: - await self.host.bridge.delContact( + await self.host.bridge.contact_del( contact, profile_key=self.host.profile) except Exception as e: self.disp(f"can't delete contact {contact!r}: {e}", error=True) @@ -310,7 +310,7 @@ async def start(self): try: - await self.host.bridge.rosterResync(profile_key=self.host.profile) + await self.host.bridge.roster_resync(profile_key=self.host.profile) except Exception as e: self.disp(f"can't resynchronise roster: {e}", error=True) self.host.quit(C.EXIT_BRIDGE_ERRBACK)