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

@ -66,7 +66,7 @@ class PubsubSigning:
def __init__(self, host):
log.info(_("Pubsub Signing plugin initialization"))
host.registerNamespace("pubsub-signing", NS_PUBSUB_SIGNING)
host.register_namespace("pubsub-signing", NS_PUBSUB_SIGNING)
self.host = host
self._p = host.plugins["XEP-0060"]
self._ox = host.plugins["XEP-0373"]
@ -75,8 +75,8 @@ class PubsubSigning:
"signature", NS_PUBSUB_SIGNING, self.signature_get, self.signature_set
)
host.trigger.add("XEP-0060_publish", self._publish_trigger)
host.bridge.addMethod(
"psSignatureCheck",
host.bridge.add_method(
"ps_signature_check",
".plugin",
in_sign="sssss",
out_sign="s",
@ -84,7 +84,7 @@ class PubsubSigning:
async_=True,
)
def getHandler(self, client):
def get_handler(self, client):
return PubsubSigning_Handler()
def get_data_to_sign(
@ -137,7 +137,7 @@ class PubsubSigning:
) -> defer.Deferred:
d = defer.ensureDeferred(
self.check(
self.host.getClient(profile_key),
self.host.get_client(profile_key),
jid.JID(service),
node,
item_id,
@ -155,7 +155,7 @@ class PubsubSigning:
item_id: str,
signature_data: Dict[str, Any],
) -> Dict[str, Any]:
items, __ = await self._p.getItems(
items, __ = await self._p.get_items(
client, service, node, item_ids=[item_id]
)
if not items != 1:
@ -254,7 +254,7 @@ class PubsubSigning:
if item_elt is None:
node = attachments_data["node"]
item_id = attachments_data["id"]
items, __ = await self._p.getItems(
items, __ = await self._p.get_items(
client, service, node, item_ids=[item_id]
)
if not items != 1: