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

@ -67,28 +67,28 @@ class XEP_0070(object):
self.host = host
self._dictRequest = dict()
def getHandler(self, client):
def get_handler(self, client):
return XEP_0070_handler(self, client.profile)
def onHttpAuthRequestIQ(self, iq_elt, client):
def on_http_auth_request_iq(self, iq_elt, client):
"""This method is called on confirmation request received (XEP-0070 #4.5)
@param iq_elt: IQ element
@param client: %(doc_client)s
"""
log.info(_("XEP-0070 Verifying HTTP Requests via XMPP (iq)"))
self._treatHttpAuthRequest(iq_elt, IQ, client)
self._treat_http_auth_request(iq_elt, IQ, client)
def onHttpAuthRequestMsg(self, msg_elt, client):
def on_http_auth_request_msg(self, msg_elt, client):
"""This method is called on confirmation request received (XEP-0070 #4.5)
@param msg_elt: message element
@param client: %(doc_client)s
"""
log.info(_("XEP-0070 Verifying HTTP Requests via XMPP (message)"))
self._treatHttpAuthRequest(msg_elt, MSG, client)
self._treat_http_auth_request(msg_elt, MSG, client)
def _treatHttpAuthRequest(self, elt, stanzaType, client):
def _treat_http_auth_request(self, elt, stanzaType, client):
elt.handled = True
auth_elt = next(elt.elements(NS_HTTP_AUTH, "confirm"))
auth_id = auth_elt["id"]
@ -100,11 +100,11 @@ class XEP_0070(object):
"Validation code : {auth_id}\n\n"
"Please check that this code is the same as on {auth_url}"
).format(auth_url=auth_url, auth_id=auth_id)
d = xml_tools.deferConfirm(self.host, message=message, title=title,
d = xml_tools.defer_confirm(self.host, message=message, title=title,
profile=client.profile)
d.addCallback(self._authRequestCallback, client)
d.addCallback(self._auth_request_callback, client)
def _authRequestCallback(self, authorized, client):
def _auth_request_callback(self, authorized, client):
try:
auth_id, auth_method, auth_url, stanzaType, elt = self._dictRequest.pop(
client)
@ -140,12 +140,12 @@ class XEP_0070_handler(XMPPHandler):
def connectionInitialized(self):
self.xmlstream.addObserver(
IQ_HTTP_AUTH_REQUEST,
self.plugin_parent.onHttpAuthRequestIQ,
self.plugin_parent.on_http_auth_request_iq,
client=self.parent,
)
self.xmlstream.addObserver(
MSG_HTTP_AUTH_REQUEST,
self.plugin_parent.onHttpAuthRequestMsg,
self.plugin_parent.on_http_auth_request_msg,
client=self.parent,
)