diff sat_frontends/jp/cmd_pipe.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 2594e1951cf7
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_pipe.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat_frontends/jp/cmd_pipe.py	Sat Apr 08 13:54:42 2023 +0200
@@ -45,7 +45,7 @@
     async def start(self):
         """ Create named pipe, and send stdin to it """
         try:
-            port = await self.host.bridge.streamOut(
+            port = await self.host.bridge.stream_out(
                 await self.host.get_full_jid(self.args.jid),
                 self.profile,
             )
@@ -89,13 +89,13 @@
         except IOError as e:
             sys.stderr.write(f"{e}\n")
             break
-    host.quitFromSignal()
+    host.quit_from_signal()
 
 
 class PipeIn(base.CommandAnswering):
     def __init__(self, host):
         super(PipeIn, self).__init__(host, "in", help=_("receive a pipe stream"))
-        self.action_callbacks = {"STREAM": self.onStreamAction}
+        self.action_callbacks = {"STREAM": self.on_stream_action}
 
     def add_parser_options(self):
         self.parser.add_argument(
@@ -104,7 +104,7 @@
             help=_('Jids accepted (none means "accept everything")'),
         )
 
-    def getXmluiId(self, action_data):
+    def get_xmlui_id(self, action_data):
         try:
             xml_ui = action_data["xmlui"]
         except KeyError:
@@ -113,13 +113,13 @@
             ui = xmlui_manager.create(self.host, xml_ui)
             if not ui.submit_id:
                 self.disp(_("Invalid XMLUI received"), error=True)
-                self.quitFromSignal(C.EXIT_INTERNAL_ERROR)
+                self.quit_from_signal(C.EXIT_INTERNAL_ERROR)
             return ui.submit_id
 
-    async def onStreamAction(self, action_data, action_id, security_limit, profile):
-        xmlui_id = self.getXmluiId(action_data)
+    async def on_stream_action(self, action_data, action_id, security_limit, profile):
+        xmlui_id = self.get_xmlui_id(action_data)
         if xmlui_id is None:
-            self.host.quitFromSignal(C.EXIT_ERROR)
+            self.host.quit_from_signal(C.EXIT_ERROR)
         try:
             from_jid = jid.JID(action_data["meta_from_jid"])
         except KeyError:
@@ -140,11 +140,11 @@
                 else:
                     break
             xmlui_data = {"answer": C.BOOL_TRUE, "port": str(port)}
-            await self.host.bridge.launchAction(
+            await self.host.bridge.action_launch(
                 xmlui_id, xmlui_data, profile_key=profile)
             async with server:
                 await server.serve_forever()
-            self.host.quitFromSignal()
+            self.host.quit_from_signal()
 
     async def start(self):
         self.bare_jids = [jid.JID(jid_).bare for jid_ in self.args.jids]