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.
This commit is contained in:
Goffi 2023-04-08 13:54:42 +02:00
commit 6a6f15707a

View file

@ -74,13 +74,13 @@ class XEP_0280(object):
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 @@ class XEP_0280(object):
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 @@ class XEP_0280(object):
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():