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

@ -29,7 +29,7 @@ from sat.core.log import getLogger
log = getLogger(__name__)
def sendEmail(config, to_emails, subject="", body="", from_email=None):
def send_email(config, to_emails, subject="", body="", from_email=None):
"""Send an email using SàT configuration
@param config (SafeConfigParser): the configuration instance
@ -42,11 +42,11 @@ def sendEmail(config, to_emails, subject="", body="", from_email=None):
"""
if isinstance(to_emails, str):
to_emails = to_emails.split()
email_host = tools_config.getConfig(config, None, "email_server") or "localhost"
email_from = from_email or tools_config.getConfig(config, None, "email_from")
email_host = tools_config.config_get(config, None, "email_server") or "localhost"
email_from = from_email or tools_config.config_get(config, None, "email_from")
# we suppose that email domain and XMPP domain are identical
domain = tools_config.getConfig(config, None, "xmpp_domain")
domain = tools_config.config_get(config, None, "xmpp_domain")
if domain is None:
if email_from is not None:
domain = email_from.split("@", 1)[-1]
@ -55,14 +55,14 @@ def sendEmail(config, to_emails, subject="", body="", from_email=None):
if email_from is None:
email_from = "no_reply@" + domain
email_sender_domain = tools_config.getConfig(
email_sender_domain = tools_config.config_get(
config, None, "email_sender_domain", domain
)
email_port = int(tools_config.getConfig(config, None, "email_port", 25))
email_username = tools_config.getConfig(config, None, "email_username")
email_password = tools_config.getConfig(config, None, "email_password")
email_auth = C.bool(tools_config.getConfig(config, None, "email_auth", C.BOOL_FALSE))
email_starttls = C.bool(tools_config.getConfig(config, None, "email_starttls",
email_port = int(tools_config.config_get(config, None, "email_port", 25))
email_username = tools_config.config_get(config, None, "email_username")
email_password = tools_config.config_get(config, None, "email_password")
email_auth = C.bool(tools_config.config_get(config, None, "email_auth", C.BOOL_FALSE))
email_starttls = C.bool(tools_config.config_get(config, None, "email_starttls",
C.BOOL_FALSE))
msg = MIMEText(body, "plain", "UTF-8")