diff sat/plugins/plugin_sec_pubsub_signing.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 d105ead599b6
children
line wrap: on
line diff
--- a/sat/plugins/plugin_sec_pubsub_signing.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/plugins/plugin_sec_pubsub_signing.py	Sat Apr 08 13:54:42 2023 +0200
@@ -66,7 +66,7 @@
 
     def __init__(self, host):
         log.info(_("Pubsub Signing plugin initialization"))
-        host.registerNamespace("pubsub-signing", NS_PUBSUB_SIGNING)
+        host.register_namespace("pubsub-signing", NS_PUBSUB_SIGNING)
         self.host = host
         self._p = host.plugins["XEP-0060"]
         self._ox = host.plugins["XEP-0373"]
@@ -75,8 +75,8 @@
             "signature", NS_PUBSUB_SIGNING, self.signature_get, self.signature_set
         )
         host.trigger.add("XEP-0060_publish", self._publish_trigger)
-        host.bridge.addMethod(
-            "psSignatureCheck",
+        host.bridge.add_method(
+            "ps_signature_check",
             ".plugin",
             in_sign="sssss",
             out_sign="s",
@@ -84,7 +84,7 @@
             async_=True,
         )
 
-    def getHandler(self, client):
+    def get_handler(self, client):
         return PubsubSigning_Handler()
 
     def get_data_to_sign(
@@ -137,7 +137,7 @@
     ) -> defer.Deferred:
         d = defer.ensureDeferred(
             self.check(
-                self.host.getClient(profile_key),
+                self.host.get_client(profile_key),
                 jid.JID(service),
                 node,
                 item_id,
@@ -155,7 +155,7 @@
         item_id: str,
         signature_data: Dict[str, Any],
     ) -> Dict[str, Any]:
-        items, __ = await self._p.getItems(
+        items, __ = await self._p.get_items(
             client, service, node, item_ids=[item_id]
         )
         if not items != 1:
@@ -254,7 +254,7 @@
             if item_elt is None:
                 node = attachments_data["node"]
                 item_id = attachments_data["id"]
-                items, __ = await self._p.getItems(
+                items, __ = await self._p.get_items(
                     client, service, node, item_ids=[item_id]
                 )
                 if not items != 1: