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

@ -58,7 +58,7 @@ class XEP_0215:
def __init__(self, host):
log.info(_("External Service Discovery plugin initialization"))
self.host = host
host.bridge.addMethod(
host.bridge.add_method(
"external_disco_get",
".plugin",
in_sign="ss",
@ -66,7 +66,7 @@ class XEP_0215:
method=self._external_disco_get,
async_=True,
)
host.bridge.addMethod(
host.bridge.add_method(
"external_disco_credentials_get",
".plugin",
in_sign="ssis",
@ -75,10 +75,10 @@ class XEP_0215:
async_=True,
)
def getHandler(self, client):
def get_handler(self, client):
return XEP_0215_handler(self)
async def profileConnecting(self, client: SatXMPPEntity) -> None:
async def profile_connecting(self, client: SatXMPPEntity) -> None:
client._xep_0215_services = {}
def parse_services(
@ -147,13 +147,13 @@ class XEP_0215:
for x_elt in service_elt.elements(data_form.NS_X_DATA, "x"):
form = data_form.Form.fromElement(x_elt)
extended = service.setdefault("extended", [])
extended.append(xml_tools.dataForm2dataDict(form))
extended.append(xml_tools.data_form_2_data_dict(form))
services.append(service)
return services
def _external_disco_get(self, entity: str, profile_key: str) -> defer.Deferred:
client = self.host.getClient(profile_key)
client = self.host.get_client(profile_key)
d = defer.ensureDeferred(
self.get_external_services(client, jid.JID(entity) if entity else None)
)
@ -204,7 +204,7 @@ class XEP_0215:
port: int = 0,
profile_key=C.PROF_KEY_NONE,
) -> defer.Deferred:
client = self.host.getClient(profile_key)
client = self.host.get_client(profile_key)
d = defer.ensureDeferred(
self.request_credentials(
client, host, type_, port or None, jid.JID(entity) if entity else None