Mercurial > libervia-backend
diff sat/bridge/bridge_constructor/constructors/dbus/dbus_frontend_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 | 71cfe9334f73 |
children |
line wrap: on
line diff
--- a/sat/bridge/bridge_constructor/constructors/dbus/dbus_frontend_template.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat/bridge/bridge_constructor/constructors/dbus/dbus_frontend_template.py Sat Apr 08 13:54:42 2023 +0200 @@ -32,8 +32,8 @@ # 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") @@ -66,9 +66,9 @@ return BridgeException(name, message, condition) -class Bridge: +class bridge: - def bridgeConnect(self, callback, errback): + def bridge_connect(self, callback, errback): try: self.sessions_bus = dbus.SessionBus() self.db_object = self.sessions_bus.get_object(const_INT_PREFIX, @@ -105,7 +105,7 @@ except AttributeError: # The attribute is not found, we try the plugin proxy to find the requested method - def getPluginMethod(*args, **kwargs): + def get_plugin_method(*args, **kwargs): # We first check if we have an async call. We detect this in two ways: # - if we have the 'callback' and 'errback' keyword arguments # - or if the last two arguments are callable @@ -156,11 +156,11 @@ return self.db_plugin_iface.get_dbus_method(name)(*args, **kwargs) raise e - return getPluginMethod + return get_plugin_method ##METHODS_PART## -class AIOBridge(Bridge): +class AIOBridge(bridge): def register_signal(self, functionName, handler, iface="core"): loop = asyncio.get_running_loop() @@ -173,7 +173,7 @@ return object.__getattribute__(self, name) except AttributeError: # The attribute is not found, we try the plugin proxy to find the requested method - def getPluginMethod(*args, **kwargs): + def get_plugin_method(*args, **kwargs): loop = asyncio.get_running_loop() fut = loop.create_future() method = getattr(self.db_plugin_iface, name) @@ -191,7 +191,7 @@ ) except ValueError as e: if e.args[0].startswith("Unable to guess signature"): - # same hack as for Bridge.__getattribute__ + # same hack as for bridge.__getattribute__ log.warning("using hack to work around inspection issue") proxy = self.db_plugin_iface.proxy_object IN_PROGRESS = proxy.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS @@ -209,12 +209,12 @@ raise e return fut - return getPluginMethod + return get_plugin_method - def bridgeConnect(self): + def bridge_connect(self): loop = asyncio.get_running_loop() fut = loop.create_future() - super().bridgeConnect( + super().bridge_connect( callback=lambda: loop.call_soon_threadsafe(fut.set_result, None), errback=lambda e: loop.call_soon_threadsafe(fut.set_exception, e) )