diff sat/plugins/plugin_misc_groupblog.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_misc_groupblog.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/plugins/plugin_misc_groupblog.py	Sat Apr 08 13:54:42 2023 +0200
@@ -61,19 +61,19 @@
         log.info(_("Group blog plugin initialization"))
         self.host = host
         self._p = self.host.plugins["XEP-0060"]
-        host.trigger.add("XEP-0277_item2data", self._item2dataTrigger)
-        host.trigger.add("XEP-0277_data2entry", self._data2entryTrigger)
-        host.trigger.add("XEP-0277_comments", self._commentsTrigger)
+        host.trigger.add("XEP-0277_item2data", self._item_2_data_trigger)
+        host.trigger.add("XEP-0277_data2entry", self._data_2_entry_trigger)
+        host.trigger.add("XEP-0277_comments", self._comments_trigger)
 
     ## plugin management methods ##
 
-    def getHandler(self, client):
+    def get_handler(self, client):
         return GroupBlog_handler()
 
     @defer.inlineCallbacks
-    def profileConnected(self, client):
+    def profile_connected(self, client):
         try:
-            yield self.host.checkFeatures(client, (NS_PUBSUB_GROUPBLOG,))
+            yield self.host.check_features(client, (NS_PUBSUB_GROUPBLOG,))
         except exceptions.FeatureNotFound:
             client.server_groupblog_available = False
             log.warning(
@@ -85,21 +85,21 @@
             client.server_groupblog_available = True
             log.info(_("Server can manage group blogs"))
 
-    def getFeatures(self, profile):
+    def features_get(self, profile):
         try:
-            client = self.host.getClient(profile)
+            client = self.host.get_client(profile)
         except exceptions.ProfileNotSetError:
             return {}
         try:
-            return {"available": C.boolConst(client.server_groupblog_available)}
+            return {"available": C.bool_const(client.server_groupblog_available)}
         except AttributeError:
-            if self.host.isConnected(profile):
+            if self.host.is_connected(profile):
                 log.debug("Profile is not connected, service is not checked yet")
             else:
                 log.error("client.server_groupblog_available should be available !")
             return {}
 
-    def _item2dataTrigger(self, item_elt, entry_elt, microblog_data):
+    def _item_2_data_trigger(self, item_elt, entry_elt, microblog_data):
         """Parse item to find group permission elements"""
         config_form = data_form.findForm(item_elt, NS_PUBSUB_ITEM_CONFIG)
         if config_form is None:
@@ -109,7 +109,7 @@
             opt = self._p.OPT_ROSTER_GROUPS_ALLOWED
             microblog_data['groups'] = config_form.fields[opt].values
 
-    def _data2entryTrigger(self, client, mb_data, entry_elt, item_elt):
+    def _data_2_entry_trigger(self, client, mb_data, entry_elt, item_elt):
         """Build fine access permission if needed
 
         This trigger check if "group*" key are present,
@@ -130,7 +130,7 @@
         form.addField(allowed)
         item_elt.addChild(form.toElement())
 
-    def _commentsTrigger(self, client, mb_data, options):
+    def _comments_trigger(self, client, mb_data, options):
         """This method is called when a comments node is about to be created
 
         It changes the access mode to roster if needed, and give the authorized groups