diff sat/bridge/bridge_constructor/constructors/dbus/dbus_core_template.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 60d3861e5996
children
line wrap: on
line diff
--- a/sat/bridge/bridge_constructor/constructors/dbus/dbus_core_template.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/bridge/bridge_constructor/constructors/dbus/dbus_core_template.py	Sat Apr 08 13:54:42 2023 +0200
@@ -30,8 +30,8 @@
 log = getLogger(__name__)
 
 # Interface prefix
-const_INT_PREFIX = config.getConfig(
-    config.parseMainConf(),
+const_INT_PREFIX = config.config_get(
+    config.parse_main_conf(),
     "",
     "bridge_dbus_int_prefix",
     "org.libervia.Libervia")
@@ -118,13 +118,13 @@
 
 ##METHODS_PART##
 
-class Bridge:
+class bridge:
 
     def __init__(self):
         log.info("Init DBus...")
         self._obj = DBusObject(const_OBJ_PATH)
 
-    async def postInit(self):
+    async def post_init(self):
         try:
             conn = await client.connect(reactor)
         except error.DBusException as e:
@@ -145,13 +145,13 @@
         log.debug(f"registering DBus bridge method [{name}]")
         self._obj.register_method(name, callback)
 
-    def emitSignal(self, name, *args):
+    def emit_signal(self, name, *args):
         self._obj.emitSignal(name, *args)
 
-    def addMethod(
+    def add_method(
             self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}
     ):
-        """Dynamically add a method to D-Bus Bridge"""
+        """Dynamically add a method to D-Bus bridge"""
         # FIXME: doc parameter is kept only temporary, the time to remove it from calls
         log.debug(f"Adding method {name!r} to D-Bus bridge")
         self._obj.plugin_iface.addMethod(
@@ -164,8 +164,8 @@
         setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj))
         self.register_method(name, method)
 
-    def addSignal(self, name, int_suffix, signature, doc={}):
-        """Dynamically add a signal to D-Bus Bridge"""
+    def add_signal(self, name, int_suffix, signature, doc={}):
+        """Dynamically add a signal to D-Bus bridge"""
         log.debug(f"Adding signal {name!r} to D-Bus bridge")
         self._obj.plugin_iface.addSignal(Signal(name, signature))
-        setattr(Bridge, name, partialmethod(Bridge.emitSignal, name))
+        setattr(bridge, name, partialmethod(bridge.emit_signal, name))