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

@ -92,9 +92,9 @@ class XEP_0374:
sat.trigger.add("send", self.__send_trigger, priority=0)
# Register the encryption plugin
sat.registerEncryptionPlugin(self, "OXIM", NS_OX, 102)
sat.register_encryption_plugin(self, "OXIM", NS_OX, 102)
async def getTrustUI( # pylint: disable=invalid-name
async def get_trust_ui( # pylint: disable=invalid-name
self,
client: SatXMPPClient,
entity: jid.JID
@ -106,7 +106,7 @@ class XEP_0374:
devices belonging to the entity.
"""
return await self.__xep_0373.getTrustUI(client, entity)
return await self.__xep_0373.get_trust_ui(client, entity)
@staticmethod
def __get_joined_muc_users(
@ -126,7 +126,7 @@ class XEP_0374:
bare_jids: Set[jid.JID] = set()
try:
room = cast(muc.Room, xep_0045.getRoom(client, room_jid))
room = cast(muc.Room, xep_0045.get_room(client, room_jid))
except exceptions.NotFound as e:
raise exceptions.InternalError(
"Participant list of unjoined MUC requested."
@ -176,7 +176,7 @@ class XEP_0374:
room_jid = feedback_jid = sender_jid.userhostJID()
try:
room = cast(muc.Room, self.__xep_0045.getRoom(client, room_jid))
room = cast(muc.Room, self.__xep_0045.get_room(client, room_jid))
except exceptions.NotFound:
log.warning(
f"Ignoring MUC message from a room that has not been joined:"
@ -272,13 +272,13 @@ class XEP_0374:
# Mark the message as trusted or untrusted. Undecided counts as untrusted here.
trust_level = TrustLevel.UNDECIDED # TODO: Load the actual trust level
if trust_level is TrustLevel.TRUSTED:
post_treat.addCallback(client.encryption.markAsTrusted)
post_treat.addCallback(client.encryption.mark_as_trusted)
else:
post_treat.addCallback(client.encryption.markAsUntrusted)
post_treat.addCallback(client.encryption.mark_as_untrusted)
# Mark the message as originally encrypted
post_treat.addCallback(
client.encryption.markAsEncrypted,
client.encryption.mark_as_encrypted,
namespace=NS_OX
)
@ -326,7 +326,7 @@ class XEP_0374:
)
# Add a store hint if this is a message stanza
self.__xep_0334.addHintElements(stanza, [ "store" ])
self.__xep_0334.add_hint_elements(stanza, [ "store" ])
# Let the flow continue.
return True