diff sat/tools/common/email.py @ 4037:524856bd7b19

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.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents 2c187445a3d3
children
line wrap: on
line diff
--- a/sat/tools/common/email.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/tools/common/email.py	Sat Apr 08 13:54:42 2023 +0200
@@ -29,7 +29,7 @@
 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 @@
     """
     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 @@
 
     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")