diff sat/tools/config.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 3c7a64d6f49f
children
line wrap: on
line diff
--- a/sat/tools/config.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/tools/config.py	Sat Apr 08 13:54:42 2023 +0200
@@ -34,7 +34,7 @@
 log = getLogger(__name__)
 
 
-def fixConfigOption(section, option, value, silent=True):
+def fix_config_option(section, option, value, silent=True):
     """Force a configuration option value
 
     the option will be written in the first found user config file, a new user
@@ -75,7 +75,7 @@
                                                 config_file=target_file))
 
 
-def parseMainConf(log_filenames=False):
+def parse_main_conf(log_filenames=False):
     """Look for main .ini configuration file, and parse it
 
     @param log_filenames(bool): if True, log filenames of read config files
@@ -99,7 +99,7 @@
     return config
 
 
-def getConfig(config, section, name, default=None):
+def config_get(config, section, name, default=None):
     """Get a configuration option
 
     @param config (ConfigParser): the configuration instance
@@ -145,7 +145,7 @@
     return value
 
 
-def getConf(
+def get_conf(
     conf: ConfigParser,
     prefix: str,
     section: str,
@@ -168,4 +168,4 @@
     """
     # XXX: This is a temporary method until parameters are refactored
     value = os.getenv(f"LIBERVIA_{prefix}_{name}".upper())
-    return value or getConfig(conf, section, f"{prefix}_{name}", default)
+    return value or config_get(conf, section, f"{prefix}_{name}", default)