Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0280.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 | c23cad65ae99 |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0280.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat/plugins/plugin_xep_0280.py Sat Apr 08 13:54:42 2023 +0200 @@ -74,13 +74,13 @@ def __init__(self, host): log.info(_("Plugin XEP_0280 initialization")) self.host = host - host.memory.updateParams(self.params) - host.trigger.add("messageReceived", self.messageReceivedTrigger, priority=200000) + host.memory.update_params(self.params) + host.trigger.add("messageReceived", self.message_received_trigger, priority=200000) - def getHandler(self, client): + def get_handler(self, client): return XEP_0280_handler() - def setPrivate(self, message_elt): + def set_private(self, message_elt): """Add a <private/> element to a message this method is intented to be called on final domish.Element by other plugins @@ -93,16 +93,16 @@ message_elt.addElement((NS_CARBONS, "private")) @defer.inlineCallbacks - def profileConnected(self, client): + def profile_connected(self, client): """activate message carbons on connection if possible and activated in config""" - activate = self.host.memory.getParamA( + activate = self.host.memory.param_get_a( PARAM_NAME, PARAM_CATEGORY, profile_key=client.profile ) if not activate: log.info(_("Not activating message carbons as requested in params")) return try: - yield self.host.checkFeatures(client, (NS_CARBONS,)) + yield self.host.check_features(client, (NS_CARBONS,)) except exceptions.FeatureNotFound: log.warning(_("server doesn't handle message carbons")) else: @@ -116,7 +116,7 @@ else: log.info(_("message carbons activated")) - def messageReceivedTrigger(self, client, message_elt, post_treat): + def message_received_trigger(self, client, message_elt, post_treat): """get message and handle it if carbons namespace is present""" carbons_elt = None for e in message_elt.elements():