diff sat_frontends/jp/cmd_message.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 78b5f356900c
children 4b842c1fb686
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_message.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat_frontends/jp/cmd_message.py	Sat Apr 08 13:54:42 2023 +0200
@@ -91,7 +91,7 @@
             "jid", help=_("the destination jid")
         )
 
-    async def sendStdin(self, dest_jid):
+    async def send_stdin(self, dest_jid):
         """Send incomming data on stdin to jabber contact
 
         @param dest_jid: destination jid
@@ -123,7 +123,7 @@
             if header:
                 # first we sent the header
                 try:
-                    await self.host.bridge.messageSend(
+                    await self.host.bridge.message_send(
                         dest_jid,
                         {self.args.lang: header},
                         subject,
@@ -160,7 +160,7 @@
                 # first one
                 del extra[C.KEY_ATTACHMENTS]
             try:
-                await self.host.bridge.messageSend(
+                await self.host.bridge.message_send(
                     dest_jid,
                     msg,
                     subject,
@@ -193,21 +193,21 @@
 
         if self.args.encrypt is not None:
             try:
-                namespace = await self.host.bridge.encryptionNamespaceGet(
+                namespace = await self.host.bridge.encryption_namespace_get(
                     self.args.encrypt)
             except Exception as e:
                 self.disp(f"can't get encryption namespace: {e}", error=True)
                 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
 
             try:
-                await self.host.bridge.messageEncryptionStart(
+                await self.host.bridge.message_encryption_start(
                     jid_, namespace, not self.args.encrypt_noreplace, self.profile
                 )
             except Exception as e:
                 self.disp(f"can't start encryption session: {e}", error=True)
                 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
 
-        await self.sendStdin(jid_)
+        await self.send_stdin(jid_)
 
 
 class Retract(base.CommandBase):
@@ -223,7 +223,7 @@
 
     async def start(self):
         try:
-            await self.host.bridge.messageRetract(
+            await self.host.bridge.message_retract(
                 self.args.message_id,
                 self.profile
             )
@@ -286,7 +286,7 @@
             if value is not None:
                 extra[key] = str(value)
         try:
-            data, metadata_s, profile = await self.host.bridge.MAMGet(
+            data, metadata_s, profile = await self.host.bridge.mam_get(
                 self.args.service, data_format.serialise(extra), self.profile)
         except Exception as e:
             self.disp(f"can't retrieve MAM archives: {e}", error=True)
@@ -295,7 +295,7 @@
         metadata = data_format.deserialise(metadata_s)
 
         try:
-            session_info = await self.host.bridge.sessionInfosGet(self.profile)
+            session_info = await self.host.bridge.session_infos_get(self.profile)
         except Exception as e:
             self.disp(f"can't get session infos: {e}", error=True)
             self.host.quit(C.EXIT_BRIDGE_ERRBACK)