diff sat/plugins/plugin_xep_0020.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 be6d91572633
children
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0020.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/plugins/plugin_xep_0020.py	Sat Apr 08 13:54:42 2023 +0200
@@ -51,10 +51,10 @@
     def __init__(self, host):
         log.info(_("Plugin XEP_0020 initialization"))
 
-    def getHandler(self, client):
+    def get_handler(self, client):
         return XEP_0020_handler()
 
-    def getFeatureElt(self, elt):
+    def get_feature_elt(self, elt):
         """Check element's children to find feature elements
 
         @param elt(domish.Element): parent element of the feature element
@@ -67,7 +67,7 @@
             raise exceptions.NotFound
         return feature_elt
 
-    def _getForm(self, elt, namespace):
+    def _get_form(self, elt, namespace):
         """Return the first child data form
 
         @param elt(domish.Element): parent of the data form
@@ -84,7 +84,7 @@
         else:
             return data_form.findForm(elt, namespace)
 
-    def getChoosedOptions(self, feature_elt, namespace):
+    def get_choosed_options(self, feature_elt, namespace):
         """Return choosed feature for feature element
 
         @param feature_elt(domish.Element): feature domish element
@@ -92,7 +92,7 @@
         @return (dict): feature name as key, and choosed option as value
         @raise exceptions.NotFound: not data form is found
         """
-        form = self._getForm(feature_elt, namespace)
+        form = self._get_form(feature_elt, namespace)
         if form is None:
             raise exceptions.NotFound
         result = {}
@@ -117,14 +117,14 @@
         @param namespace (None, unicode): form namespace or None to ignore
         @raise KeyError: name is not found in data form fields
         """
-        form = self._getForm(feature_elt, namespace)
+        form = self._get_form(feature_elt, namespace)
         options = [option.value for option in form.fields[name].options]
         for value in negotiable_values:
             if value in options:
                 return value
         return None
 
-    def chooseOption(self, options, namespace):
+    def choose_option(self, options, namespace):
         """Build a feature element with choosed options
 
         @param options(dict): dict with feature as key and choosed option as value
@@ -136,7 +136,7 @@
         feature_elt.addChild(x_form.toElement())
         return feature_elt
 
-    def proposeFeatures(self, options_dict, namespace):
+    def propose_features(self, options_dict, namespace):
         """Build a feature element with options to propose
 
         @param options_dict(dict): dict with feature as key and iterable of acceptable options as value