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:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -49,14 +49,14 @@ class RegisterAccount(object):
|
|||
log.info(_("Plugin Register Account initialization"))
|
||||
self.host = host
|
||||
self._sessions = Sessions()
|
||||
host.registerCallback(
|
||||
self.registerNewAccountCB, with_data=True, force_id="registerNewAccount"
|
||||
host.register_callback(
|
||||
self.register_new_account_cb, with_data=True, force_id="register_new_account"
|
||||
)
|
||||
self.__register_account_id = host.registerCallback(
|
||||
self._registerConfirmation, with_data=True
|
||||
self.__register_account_id = host.register_callback(
|
||||
self._register_confirmation, with_data=True
|
||||
)
|
||||
|
||||
def registerNewAccountCB(self, data, profile):
|
||||
def register_new_account_cb(self, data, profile):
|
||||
"""Called when the user click on the "New account" button."""
|
||||
session_data = {}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class RegisterAccount(object):
|
|||
|
||||
session_data["user"], host, resource = jid.parse(session_data["JabberID"])
|
||||
session_data["server"] = session_data[C.FORCE_SERVER_PARAM] or host
|
||||
session_id, __ = self._sessions.newSession(session_data, profile=profile)
|
||||
session_id, __ = self._sessions.new_session(session_data, profile=profile)
|
||||
form_ui = xml_tools.XMLUI(
|
||||
"form",
|
||||
title=D_("Register new account"),
|
||||
|
|
@ -95,30 +95,30 @@ class RegisterAccount(object):
|
|||
)
|
||||
return {"xmlui": form_ui.toXml()}
|
||||
|
||||
def _registerConfirmation(self, data, profile):
|
||||
def _register_confirmation(self, data, profile):
|
||||
"""Save the related parameters and proceed the registration."""
|
||||
session_data = self._sessions.profileGet(data["session_id"], profile)
|
||||
session_data = self._sessions.profile_get(data["session_id"], profile)
|
||||
|
||||
self.host.memory.setParam(
|
||||
self.host.memory.param_set(
|
||||
"JabberID", session_data["JabberID"], "Connection", profile_key=profile
|
||||
)
|
||||
self.host.memory.setParam(
|
||||
self.host.memory.param_set(
|
||||
"Password", session_data["Password"], "Connection", profile_key=profile
|
||||
)
|
||||
self.host.memory.setParam(
|
||||
self.host.memory.param_set(
|
||||
C.FORCE_SERVER_PARAM,
|
||||
session_data[C.FORCE_SERVER_PARAM],
|
||||
"Connection",
|
||||
profile_key=profile,
|
||||
)
|
||||
self.host.memory.setParam(
|
||||
self.host.memory.param_set(
|
||||
C.FORCE_PORT_PARAM,
|
||||
session_data[C.FORCE_PORT_PARAM],
|
||||
"Connection",
|
||||
profile_key=profile,
|
||||
)
|
||||
|
||||
d = self._registerNewAccount(
|
||||
d = self._register_new_account(
|
||||
jid.JID(session_data["JabberID"]),
|
||||
session_data["Password"],
|
||||
None,
|
||||
|
|
@ -127,14 +127,14 @@ class RegisterAccount(object):
|
|||
del self._sessions[data["session_id"]]
|
||||
return d
|
||||
|
||||
def _registerNewAccount(self, client, jid_, password, email, server):
|
||||
def _register_new_account(self, client, jid_, password, email, server):
|
||||
# FIXME: port is not set here
|
||||
def registeredCb(__):
|
||||
def registered_cb(__):
|
||||
xmlui = xml_tools.XMLUI("popup", title=D_("Confirmation"))
|
||||
xmlui.addText(D_("Registration successful."))
|
||||
return {"xmlui": xmlui.toXml()}
|
||||
|
||||
def registeredEb(failure):
|
||||
def registered_eb(failure):
|
||||
xmlui = xml_tools.XMLUI("popup", title=D_("Failure"))
|
||||
xmlui.addText(D_("Registration failed: %s") % failure.getErrorMessage())
|
||||
try:
|
||||
|
|
@ -146,8 +146,8 @@ class RegisterAccount(object):
|
|||
pass
|
||||
return {"xmlui": xmlui.toXml()}
|
||||
|
||||
registered_d = self.host.plugins["XEP-0077"].registerNewAccount(
|
||||
registered_d = self.host.plugins["XEP-0077"].register_new_account(
|
||||
client, jid_, password, email=email, host=server, port=C.XMPP_C2S_PORT
|
||||
)
|
||||
registered_d.addCallbacks(registeredCb, registeredEb)
|
||||
registered_d.addCallbacks(registered_cb, registered_eb)
|
||||
return registered_d
|
||||
|
|
|
|||
Loading…
Reference in a new issue